Git使用技巧

  1. 怎么把修改commit到两个或多个branche
git checkout A
git commit -m "Fixed the bug x"
git checkout B
git cherry-pick A
  1. 撤销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

  1. 添加要删除的文件进.gitignore
  2. 删除缓存
git rm -r --cached .
git add .
git commit -m ".gitignore is now working"
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容