- git add =>specified single file
- git add . =>to add all file
- git commit -m "your message" =>commit with message
- git commit -a-m "your message" => the '-a' symbol only add modified or deleted tracked file,modifed or deleted file is no need more to use "git add"
- git commit --amend =>change the messge you have commited
- git status ==> file status
- git diff ==>difference
- git log ==>check history version
- git log --pretty=oneline ==>pretty show
- git reset --hard
version id
==>reset to specified version,even is desprecated version if you still know the version id - git reflog ==>to show every command you have write (to find the version you have lost )
-
git checkout -- ==> give up the change of the specific file at the workspace, and if you have delete some file wrong ,you can replace the workspace contents with the local repository contents
-
git checkout . ==>give up all the changes at the workspace
-
git reset HEAD file ==> to reset the stage content to workspace
-
git rm ==>delete the file at the local repository
-
git remote add origin https://github.com/xxx/xxx.git ==> connect local repository to remote
-
git push -u origin master ==> push local master branch to remote first time
-
git push origin master ==>push local master branch to remote after first time, need to connect local branch to remote
-
git checkout -b dev ==> create and switch to dev branch
-
git branch ==> check all the branch
-
git brach -a ==>branch local and remote
-
git checkout
brachName
==> switch tobrachName
branch, when switch branch please commit your change first -
git merge dev ==>merge the dev to current branch
-
git merge --no-commit
branchName
==> merge brachName to current brach -
git branch -d dev ==>delete the dev branch,you’d better delete it after you merge to master
-
git branch -D
branchName
==>delete forced -
git push origin dev:dev_remote ==>create remote new branch(dev is your local branch)
-
git push origin test:master ==> push test to remote master(as master)
-
git push origin :test ==>delete remote test branch
-
git push origin --delete test ==>delete remote test branch
-
git checkout origin/
remote_branch_name
==> checkout remote branch -
git clone xxx.git "filepath" ==>specify the filepath where you want to clone
-
git pull origin : ==> if local branchName is nil,default to be local current branch
-
git pull is equal to git fetch + git merge origin branch to current
-
git merge --no-ff -m "merge with no-ff" dev ===>merge dev to current branch and forbid "fast forward"mode add will commit with a new message
-
git stash ==>save current branch working space and the work space will be clean,function to create a new branch to fix some bug,and not to commit the workspace work that not finished
- git remote -v ==>check remote branch link info
- git branch –r ==> check remote branch info
- git branch --set-upstream branch-name origin/branch-name ==> if pull failed ,this command will connect local branch with remote appropriate branch
-
git tag ==> add a tag name
-
git tag default tag at latest commit,this will tag at specific commit
-
git tag -a -m "message"
-
git tag ==>show all tag
-
git show ==>see the tag info,tag is not ordered by time but charactors
-
git tag -d ==>delete a tag local,tag default not push to remote
-
git push origin :refs/tags/ ==> if tag name is push to remote ,delete local first,then delete remote
-
git push origin
-
git push origin --tags ==>push all tags once
-
git log --graph ==>see graphical of the branch merging