Git common Command notes

Source: Internet
Author: User

mkdir learngit Creating a file directory
CD Learngit into the catalogue
PWD View current directory
Cat Readme.txt Viewing file contents
GIT init initialization
git config user.name "Suxinglee"
git config user.email "[email protected]"
git add "Readme.txt" adds a file to the library two ways to add: a library that originally existed in this file, two to create a file themselves and then execute
Git commit-m "XXX"
The current state of the Git status repository
git diff readme.txt View Difference
If Git status tells you that a file has been modified, use Git diff to see what's changed.
git log View commit history to determine which version to fallback to
git reflog View the command history to determine which version to return to in the future
git log--pretty=oneline commit log line display
git reset--hard head^ fallback to previous version
git reset--hard head^^ fallback to the previous version
git reset--hard head~100 back to previous 100 versions
git reset--hard 3,628,164 fallback to the specified version
Git checkout--readme.txt
Undo all changes to the Readme.txt file in the workspace, here are two things:
One is that Readme.txt has not been put into the staging area since the modification, and now, the undo changes back to the same state as the repository;
One is that the Readme.txt has been added to the staging area and modified, and now the undo changes go back to the state that was added to the staging area.
All in all, let this file go back to the state of the last git commit or git Add.

Git reset HEAD readme.txt The staging area changes back to the workspace. When we use head, we represent the latest version.
RM test.txt with rm command Delete
git rm test.txt Remove the file from the repository
git checkout-test.txt restore deleted files
push to remote repository
git Remote add origin [Email protected]:suxinglee/myres.git to associate a remote library, use the command
Git push-u Origin master to push the MAS for the first time All contents of the TER branch
Git push origin master     Push latest changes to master
Git remote RM origin  //GIT Remote orgin removed
Clone remote repository
git clone [email protected]:suxinglee/mydemo.git
Branch
Git branch      View Branch
Git branch dev     Create branch
git checkout master   Toggle Branch
git checkout-b Dev     Express      Create and switch to the dev branch
git merge dev merges the work of the Dev branch onto the master branch
git branch-d dev Delete Dev branch
Merge branch
git merge second Merge
Git status error View
git add * Modify and add commit
git commit-m "merge ok ..."
git log--graph--p Retty=oneline--abbrev-commit View Branch merge diagram
git branch-d second Delete branch

Git Remote to view information
Git remote-v Show more detailed information
Push to remote Warehouse
git checkout-b branch-name origin/branch-name local branch for creating and remote branch
Git branch--set-upstream branch-name Origin/branch-name Establish Association of local and remote branches
Git pull fetches branches from remote
Git push Origin branch-name no conflict or resolve conflict, push will succeed
Create a label
git tag v1.0 hit a new tag
git tag v0.9 6224937 find a History version ID, fill tag
git tag View all tags
Git show v0.9 view tag details
git tag-a v0.1-m "version 0.1 released" 3628164 Create label with description, specify label name with-A,-m specify description text
git tag-d v0.1 tag is wrong or can be deleted
Git push Origin v1.0 pushes a tag to a remote
Git push Origin--tags one-time push all not yet pushed to remote local tags
The label has been pushed to remote, to remove the remote label
Git tag-d v0.9 first delete from local
git push origin:refs/tags/v0.9 is then removed from the remote. The Delete command is also push

Liao Xuefeng official website-git Tutorial

Git common Command notes

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.