git fetch origin master
git merge origin/master
//修改...
git stash
git fetch origin master
git merge origin/master
git stash pop
//解决冲突...
git add commit push
--------*--------*--------*origin
|
--------*dev
在远端分支上提交了commit1和commit2
在本地分支上提交了commit3
git checkout dev
git fetch origin master
git rebase origin/master
git status按照提示操作,不需要git commit等操作
git fetch origin remote_branch
git checkout -b dev_localbranch origin/remote_branch//新建分支指向远端
git status
git cherry-pick是本地特性,本地要有这个commit才可以被git cherry-pick
从develop分支新开的分支dev_cp,然后commit两次,这时候我develop分支只需要第二次提交的信息,步骤:
git checkout develop
git cherry-pick 第二次commitID
解决冲突...
git add .
git cherry-pick --continue
查看本地文件修改可以确认,只有第二次的改动提交了进来
git reflog 命令历史
git branch/git branch -l
git branch -r
git branch -a
git branch -vv 查看本地分支和远端分支的连接关系
git branch -m oldName newName
git show 查看最后一次的提交
git show commit-id 查看某一次的提交内容
gitk git log的可视化版本 -->很强大
git remote
git remote -v
新建分支修改的内容commit之后才和与远端分支联系的其它分支隔离,就是各个分支内容不相同
git commit
将别的分支(temp)的多次提交合并成当前分支(master)的一次提交
git checkout master
git merge --squash temp
git reset –soft 不会改变stage区,仅仅将commit回退到了指定的提交
git reset –mixed 不回改变工作区,但是会用指定的commit覆盖stage 区,之前所有暂存的内容都变为为暂存的状态
git reset –hard 使用指定的commit的内容覆盖stage区和工作区。
git master 是原始内容
git checkout -b dev //首先切换到新的分支dev
修改文件......
git add .
git commit -m "Fix"
git diff master >/path to save patch/my_test_patch
//使用patch
git apply my_test_patch
git add .
git commit -m "xx"
git push ...
git diff-index 79fd4d7 --binary > ~/Desktop/my-patch
git apply --ignore-space-change --ignore-whitespace gpatch
git log --pretty=oneline filename