Sort notes-common Git commands, notes-common git commands

Source: Internet
Author: User
Tags git commands

Sort notes-common Git commands, notes-common git commands

In Windows, configure SSH to connect to GitHub/GitLab ==> when you need it, follow the search criteria Baidu.

 

Echo "content"> file name ==> string output.

1. Global Configuration:

Git config -- global user. name "user name"

Git config -- global user. email "email address"

Note:

Removing -- global is not a global configuration. It will create. git/config in the current project directory.

 

2. view the Configuration:

Cat ~ /. Gitconfig [location:/home/user name/. gitconfig is a hidden file, which can be viewed through ls-al]

 

3. Get a Git Repository

Method 1:

Git clone address

Method 2:

Git init

If we want to associate the local repository to a remote server, we can use the git remote command:

Git remote add host name's own remote repository address

If the local repository is connected to the remote Git server, run the following command to synchronize the local repository to the remote server:

Git push host name master ==> enter the username and password of the Repository

 

4. Basic Process

1. create or modify a file.

2. Run the git add command to add new or modified files to the local cache (Index ).

3. Use the git commit-m "comment" command to submit to the local code library.

4. Use the git push command to synchronize the local code library to the remote code library.

 

5. Common commands:

Git status ==> the changed files are listed in the untracked state.

Git diff -- cached => check which files in the buffer have been modified.

Git diff branch name ==> comparison of the target branch.

Git diff branch name -- stat ==> which files of the target Branch have been modified and several lines have been modified.

Git diff branch name file name/directory name ==> compare to the target Branch file or directory.

Enter q to exit

Git rm => Delete [This is only to add the information of the deleted file to the cache or to git commit-m ].

 

Git add * => submit all modifications and new files.

Git branch ==> on which branch the git is located.

Git branch name ==> create a new branch.

Git checkout branch name ==> switch to this branch.

Git merge-m "comment" merged branch name ==> merged branch.

Git branch-d branch name ==> Delete the branch that has been merged by the current branch.

Git branch-D ==> force Delete branch.

Git reset -- hard HEAD ^ => undo a merge.

Git log ==> view logs.

Enter q to exit

Git log -- stat => displays the files modified, added, and deleted in each commit.

 

6. git tag

View git logs first

Git tag Name: the first 8 bits of commit ==> lightweight tag.

Git tag-a tag name commit first 8 bits-m' comment '=> tag object.

Git tag ==> view tags.

Git tag-d tag name ==> Delete local tag.

 

Related Article

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.