Install and use Git

Source: Internet
Author: User
Tags git clone repository

Install and use Git

In actual project development, we often use some version controllers to host our own code. Today we will summarize the usage of Git. If you don't talk much about it, open it directly.

Objective: To manage github-managed project code through Git

1. Download and install Git

1. Download the Git official address: https://git-scm.com/download/win

2. After downloading, double-click to install

3. Select the installation directory

4. Select Components

5. Set the Start Menu directory name

6. Select the command line Environment

7. By default, click Next.

8. Installation Complete

9. Check whether the installation is successful.

Go back to the desktop and right-click the computer. If you see two git words, the installation is successful.

 

2. Git basic workflow

1. Git work zone

  

2. Add a file to the repository

  

Iii. Git initialization and repository creation and operations

1. Some basic information needs to be set after Git is installed

A. Set the user name: git config -- global user. name 'user name registered on github ';

B. Set the user email address: git config -- global user. email 'mailbox at Registration ';

Note: The configuration will show who submitted the file on the github homepage.

C. After configuring OK, run the following command to check whether the configuration is successful:

Git config -- list

Note: The git config -- global parameter indicates that all git Repositories on your machine use this configuration. You can also specify different user names and mailboxes for a repository.

2. initialize a new git Repository

  A. Create a folder

Method 1: Right-click and choose ">" Create a folder named test1 ".

Method 2: Use git to create: $ mkdir test1

  B. initialize git in the file (create a git repository)

Method 1: Enter $ cd test1

Method 1: Right-click the test1 file and choose Git Bash Here-> enter $ git int.

3. Add files to the repository  

Method 1:Use the editor to create a new index.html File

  Method 2: run the git command. $ Touch 'file', add the file to the temporary storage area through $ git add' filename, and submit the operation.

4. Modify the repository file

  Method 1:Use the editor to open index.html for modification.

  Method 2: run the git command. $ Vi 'filename ', write content in the middle, and finally submit the operation

5. Delete the repository file

Method 1: delete the file to be deleted in the editor.

Method 2: Use git to delete: $ git rm 'file' and submit the operation.

Iv. Git remote repository Management

1. Purpose of using remote warehouse:Backup and centralized management of code sharing

Git remote repository is actually a git repository file that is kept on the server.

 

 

 

5. Git clone operation

Objective: To copy a remote repository (A github project) to a local device

1. Code:Git clone repository address

The repository address comes from the following:

2. clone a project

3. Synchronize the local repository to the git remote Repository: git push

Errors may occur: 

 A. a submission error occurs.

Solution: this is an error occurred when submitting through Git GUI. the file in the git folder is set to "read-only. remove the read-only attributes of all files, folders, and their sub-files in the git folder.

 

 B. If synchronization fails or you do not have the permission, the solution is as follows:

The user name and password must be consistent with those on github.

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.