refer url http://stormzhang.com/github/2016/05/30/learn-github-from-zero3/
- git init //init github repository
- git status //check git status
- git add //add into cache
- git rm --cached //remove from cache
- git commit -m "commit info" // commit with commit info
- git log //to check commit log
- git branch // to create a new branch named
- git checkout // to switch to branch
- git checkout -b // to renew a branch and auto-switch to it.
- list all of the branch
git branch -a - fetch remote branch to local, if branchname not exist in local, it will be created
git fetch origin "remote-branchname":"local-branchname" - checkout remote branch to local and switch to the branch
git checkout origin/"remote-branchname" -b "local-branchname"
- git checkout master // first switch branch to master
- git merge // second merge to master
- git branch -d // to delete branch
- git branch -D // to force delete branch
# delete remote branch
git branch -r -d origin/branch-name
git push origin :branch-name
- git tag // to show tags
- git tag // to renew a tag named
- git checkout // to switch the tag to
- git tag -a -m "comment" // to add annotated tag with comment
- git tag -d // delete local tag
- git push origin :refs/tags/ // delete remote tag
- git push origin // to commit tag
to set the authentication refer http://stormzhang.com/github/2016/06/04/learn-github-from-zero4/
- git clone git@github.com:/.git // to get the remote repository
- git remote add origin git@github.com:/.git //to attach local repository with remote's
- git remote -v // to show the remote repository name
- git push origin master // to push local code to remote master branch
- git pull origin master // to update local code with remote branch. We usually first pull the remote code to local before push.
- git config --global user.name "hatcherfang"
- git config --global user.email "hatcherfang@163.com"
- to check the config file
vim .git/config
- git fetch git@github.com:/.git // to update the local repository
- git diff // to diff the file with updated
- git rm // to remove the file from repository
- git mv // to rename the to
-
Checked for existing SSH keys
ls ~/.ssh/
If id_rsa.pub not exists, go to step 2. -
Generated a new SSH key and added it to the ssh-agent
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"ssh-add ~/.ssh/id_rsa
- copy SSH key
id_rsa.pub(~/.ssh/id_rsa.pub) to your github account - try to use git clone
repo pathto download code
git checkout -b my-test //create local branch my-test under current branch
git push origin my-test //push my-test branch to remote
git branch --set-upstream-to=origin/my-test //将本地分支my-test关联到远程分支my-test上
git branch -a // to check remote branch
