Common git commands

Source: Internet
Author: User
Tags diff tagname version control system git commands

turn from: Http://www.cnblogs.com/idche/archive/2011/07/05/2098165.htmlGIT

Study NotesCentralized version control systemCVCS (centralized Version Control System)distributed version control systemDVCS (decentralized Version Control System) Git Basic Essentials http://progit.org/book/zh/ch1-3.html 1: Direct snapshot, not comparison difference 2: Nearly all operations can be performed locally 3 : Maintain data integrity at all times (Git uses the SHA-1 algorithm to calculate the checksum of the data, consisting of 40 hexadecimal characters (0-9 and A-f) 4: Most operations only add Data 5: three states (committed (committed), modified (modified), and staged (staged) ) git install http://progit.org/book/zh/ch1-4.htmlConfigurationgit http://progit.org/book/zh/ch1-5.html $ git config--global user.name "John Doe"//global is valid for all repo $ git config-- Global user.email [email protected]View Configurationgit config--list1. GIT BasicsInitializing the Warehouse$ git init$ git add *.c$ git add readme$ git commit-m ' initial project version 'cloning from an existing warehouse$ git clone git://github.com/schacon/grit.gitWarehouse Status$ git statustrack new Files$ git Add fileNameIgnore some files$ cat. gitignore*. [OA]//Ignore files ending with. O or. A *~//Ignore All files ending with a tilde (~)to view updates that have been staged and not staged$ git diff$ git diff--cached//The difference between a file that has been staged and a snapshot from the last commitSubmit Updates$ git commit-m "message"//Simple Commit method $ git commit-a-M "Message"//Skip the Add stepSubmit all files that have been trackedRemove files from$git rm filename$ git rm--cached readme.txt//Remove trace but do not delete fileMoving Files$ git mv file_from file_toLog$ git log$ git log–p-2//-P Submissions Differences-2 last two times$ git log--stat//show a summary of incremental row count statisticsModify the last commit$ git commit--amend//---2nd commit modified for the first time commit $ git commit-m ' initial commit ' $ git add forgotten_file$ git commit--amendcancel a file that has been staged$ git reset HEAD fileNameCancel the modification of the file (fallback to a previously unmodified state)//Very usefulIt 's dangerous, too .$ git checkout--fileName2. Use of remote warehouses    View the current remote library$ git remote-v//-VList remote AddressesAdd a remote repository$ git remote add Name git://github.com/paulboone/ticgit.gitfetching data from a remote repository$ git fetch [remote-name]$ git pull//Merge all branches of remote to local (indeterminate)push data to a remote repository$ GIT push origin master//push origin to masterView Remote Warehouse information$ git Remote show origindeletion and renaming of remote warehouses$ git remote rename PB paul//PB changed to Paul branch corresponding prefix will also change $ git remote rm paul//seemingly deleted3. Marking TagsHttp://progit.org/book/zh/ch2-6.htmlList Existing labels$ git tag$ git tag-l ' v1.4.2.* '//Search tagsnew Label$ git tag-a v1.4-m ' my version 1.4 '//new v1.4 tag message is my version 1.4Share Tags$ GIT push origin [tagname]//Submit a tag $ Git push origin--tags//push all local tagsDelete$ git tag-d [tagname]//delete tag $ git push origin:refs/tags/tagname//Delete remote tag4. Tips and TricksTips//two times tabGit Command Aliases
     
$ git config--global alias.co checkout//git co instead of git checkout
$ git config--global alias.st status
$ git config--global alias.ci commit
$ git config--global alias.br branch
$ git config--global alias.unstage reset HEAD--
$ git config--global alias.last log-1 HEAD
Of course it is best to modify the vi ~/.gitconfig file by modifying the format as
[Alias]
St = Status
.....5. Branch Create a branch$ git Branch testing//Create testing$ git checkout testing//switch to testing$ git checkout-b iss53//Create and switch to iss53$ git merge Hotfi X//Merge the hotfix branch into the current branchView Branches$ git branch-v//last commit info $ git Branch--merged | --no-merged//filter out the branch you have (or haven't) merged with the current branchDelete$ git branch-d TestingPush
$ GIT push origin serverfix//pushes the current to the Serverfix branch, omitting the remote branch name, indicating that there is a tracing relationship between the current branch and the remote branch, and the same local branch name can be omitted
$ git push < remote host name > < local branch name >:< Remote Branch name >//And pull instead, GIT pull < remote host > < source _ remote Branch name >:< Destination _ local branch name >
Update synchronization

Delete Remote Branch

6. Git on the server

Generate SSH Public key

7. Storage
Reference Http://zh.wikipedia.org/wiki/Git http://progit.org/book/zh/

Common git commands

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.