[Practical Git] Clean up commits with git rebase
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了[Practical Git] Clean up commits with git rebase,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1790字,纯文字阅读大概需要3分钟。
内容图文
![[Practical Git] Clean up commits with git rebase](/upload/InfoBanner/zyjiaocheng/1185/c97ef3c6906e4c5ca804584a70c32a4a.jpg)
Sometimes its nice to clean up commits before merging them into your main code repo; in this lesson, we go over using git rebase
to squash
commits together and then rename the condensed commit message. We also talk about potential issues with rebasing and where to be careful.
// First, you can fetch the remote branch git fetch // Then can see the logs between remote branch and local branch git log origin/master..
git rebase -i origin/master
One thing to note is that a rebase is destructive. It actually changes your Git history. You shouldn‘t use a rebase on code that‘s already been put in your master branch on your remote repository that other developers might be using. A rebase has the same function as a Git merge, but it cleans up and destroys history, whereas a merge preserves all history, and includes a merge commit.
The bottom line is that, as long as you only need to clean up commits that you‘ve made locally or in a pull request branch, you can use rebase to clean them up before you merge them into your main master branch.
If you have already pushed your commits to a pull request branch, then after you run the rebase, because it‘s destructive, you‘ll need to run:
git push -f
, for force, to let Git know that you‘re OK with destroying the history that‘s in a remote branch.
Again, be careful with this, and only use a rebase and a force push if you‘re working on code that hasn‘t been made public yet. One other thing to note is that, if at any time during a rebase, you realize you‘ve made a mistake, you can get run the Git rebase command with the abort flag to stop the rebase, and return your repo to its state before you started the rebase.
git rebase --abort
原文:http://www.cnblogs.com/Answer1215/p/5763458.html
内容总结
以上是互联网集市为您收集整理的[Practical Git] Clean up commits with git rebase全部内容,希望文章能够帮你解决[Practical Git] Clean up commits with git rebase所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。