Git使用技巧
2016-01-14 本文已影响32人
Harvace
- 怎么把修改commit到两个或多个branche
git checkout A
git commit -m "Fixed the bug x"
git checkout B
git cherry-pick A
- 撤销commit
git reset --soft HEAD~
3.回滚到过去某一个commit,并把这个作为最新的commmit
# Reset the index to the desired tree
git reset 56e05fced
# Move the branch pointer back to the previous HEAD
git reset --soft HEAD@{1}
git commit -m "Revert to 56e05fced"
# Update working copy to reflect the new commit
git reset --hard
git ignore
- 添加要删除的文件进.gitignore
- 删除缓存
git rm -r --cached .
git add .
git commit -m ".gitignore is now working"