Build a git environment in Linux
1. Create GitHub account, https://github.com
2. Create an SSH key in Linux:
Ssh-keygen # Always default
3. Add the public key to the GitHub account information account settings-> SSH key
4. test whether the verification is successful.
Ssh-T git@github.comHi someone! You 've successfully authenticated, but GitHub does not provide shell access.
Synchronize GitHub to local
1. Copy the project to a local device:
Git clone git: // github.com: xxxx/test. git # clone to local in gitreadonly mode, you can only read git clone git@github.com: xxx/test. git # clone to local SSH mode, can read and write git clone https://github.com/xxx/test.git # clone to local in https mode, can read and write git fetch git@github.com: xxx/xxx. git # Get local but not merge git pull git@github.com: xxx/xxx. git ## obtain and merge the content locally
Submit the project locally to GitHub
1. Local Configuration
Git config -- global user. Name 'onovps 'git config -- global user. Email 'onovps @ onovps.com '# global contact information, optional
2. Create a git project and submit it to GitHub.
Mkdir testdir & CD testdirtouch readme. mdgit init # initialize a local repository git add readme. MD # Add the file to the local repository git RM readme. MD # Delete git commit-M "first commit" # submit it to the local database and make remarks. The change is still made locally. Git commit-A # automatically update the changed file, A can be understood as autogit remote add XXX git@github.com: xxx/xxx. Git # Add a remote server alias. Git remote rm xxx # Delete the remote repository alias git push-u remotename master # submit the local file to the GitHub remoname repository. In this case, the local change is updated to the GitHub service.
Branch version operations
1. Create and merge branches
Git branch # display current branch is mastergit Branch New-feature # create branch git checkout New-feature # switch to new branch VI page_cache.inc.phpgit add page_cache.inc.phpgit commit-a-m "added initial version of page Cache "Git push origin New-feature # submit the branch to the remote server, it only submits the branch structure and content to the remote, and does not merge with the trunk.
2. If the new-feature branch is mature, it is necessary to merge it into the master
Git checkout master # switch to the new master git merge New-feature # merge the branches into the master git branch # display that the current branch is mastergit push # in this case, the master also incorporates the New-featureCode
Git command use mind chart:【Very expected]
Http://www.cnblogs.com/1-2-3/archive/2010/07/18/git-commands.html