First, Git experience
Msysgit is a Windows version of Git, downloaded from http://msysgit.github.io/, and then installed by default.
Git is a distributed Code management tool, remote code management is SSH-based, so to use the remote git requires SSH configuration.
The SSH configuration for GitHub is as follows: 1, set Git's user name and email:
$ git config--global"liujin"--global"[email Protected]"
2. Generate SSH Key process:
To see if you already have an SSH key:
CD ~/.ssh
If there is no key then there will be no such folder, there is a backup to delete
Survival key:
$ ssh-keygen-t rsa-c "[Email protected]"
Press 3 to enter, the password is empty.
in/home/tekkub/.ssh/ in/home/tekkub/.ssh/is: ... .......
Finally, two files were obtained: Id_rsa and id_rsa.pub3. Adding SSH keys on GitHub
Clip < Id_rsa.pub
Open https://github.com/, login >settings>ssh keys>add ssh key, and then paste ssh. 4. Test: SSH [email protected]
[Email protected] ~/457375608! You'vesuccessfully authenticated, but GitHub does isn't provide shell access. Connection to github.com closed.
Second, use GITHUB1, create a remote empty warehouse (server)
$ cd ~--bare Init
2. Local warehouse related to GitHub warehouse
" Test " $ git Remote add origin [email protected]:457375608/test.git$ git push Origin master
3. Clone a github repository to a local
$ git clone [email protected]:457375608/"20150726"$ git push origin master< /c11>
Third, branch 1, view branches:
To view the local branch:
$ git Branch
viewing remote branches
$ git branch-r
2. Create a branch:
Create local branch (after branching, still stuck in current branch, switch branch: git checkout branchname)
$ git Branch Branchname
Switch to a new branch after creating a branch
$ git checkout-b branchname
3. Submit a branch:
Submit to Remote Branch
' my new branch ' git push Origin branchname:branchname
If you want to commit a local branch mybranch to a remote repository and act as the master branch of the remote repository
$ GIT push origin Mybranch:master
4. Delete branch:
Delete Remote Branch
$ git push origin:branchname
Delete local branch, force delete with-D
$ git branch-d branchname
5. Merging branches
Merge the branch Branchname and the current branch
$ git Merge Branchname
Iv. fallback
$ git reset HEAD
Discard staging Area changes, undo staging area's changes (Unstage), and re-return to the workspace
$ git Reset--Hard head abandons the workspace and index changes, and the head pointer still points to the current commit. Undo the merge without commit, in fact the principle is to abandon the index and workspace changes, Because no commit changes exist only in the index and workspace. $ git reset--hard head^ is used to undo the contents of the commit (equivalent to git reset--hard head~1). The principle is to discard the workspace and index changes, while the head pointer points to the previous commit object. $ git reset HEAD^#Fallback all content to previous version$ git reset HEAD^ a.py#Fallback a.py version of this file to previous version$ git reset--soft head~3#3 versions forward fallback$ git reset--hard Origin/master#fallback the local state to be the same as the remote$ git reset 057d#fallback to a version
V. Temporary storage
' submit to Staging area ' git stash apply [email Protected]{index} revert to the first? A staging area git stash list view has a few staging area git stash clear Delete all staging area git stash drop [email protected]{index} Delete section? A staging Area
Basic use of Git