惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Visual Studio Blog
罗磊的独立博客
小众软件
小众软件
T
Tailwind CSS Blog
宝玉的分享
宝玉的分享
博客园_首页
N
Netflix TechBlog - Medium
B
Blog
Recent Announcements
Recent Announcements
Y
Y Combinator Blog
Blog — PlanetScale
Blog — PlanetScale
L
LangChain Blog
F
Fortinet All Blogs
The GitHub Blog
The GitHub Blog
Stack Overflow Blog
Stack Overflow Blog
C
Check Point Blog
Last Week in AI
Last Week in AI
Jina AI
Jina AI
V
V2EX
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 叶小钗
博客园 - 【当耐特】

jdhao's digital space

Conversion between base64 and OpenCV or PIL Image 腾讯云对象存储博客图床开启 CDN 加速(不需要购买额外域名) Search and Replace in Multiple Files in Vim/Neovim Change Table Column Width in LaTeX Image or Table Side by Side in LaTeX LaTeX 并排显示图像或表格 Firenvim: Neovim inside Your Browser Content inside HTML tags missing in Latest Hugo? Creating Markdown Front Matter with Ultisnips Labelme JSON 标注格式转 voc XML 格式 Nifty Nvim Techniques That Make My Life Easier -- Series 6 macOS 下如何为视频制作字幕 Running Command Asynchronously inside Neovim Resolving Merge Conflict after Git Stash Pop Pylint: command not found? A Hands-on Experience with Neovim's Built-in LSP Support How to Convert PDF to Images with Imagemagick 互联网上常用缩略语集锦 File Backup in Neovim Converting PDF Pages to Images with Poppler Nifty Nvim Techniques That Make My Life Easier -- Series 5 Neovim Configuration for System-wide Use How to sort a list of tuple or list in Python -- lambda or itemgetter? Building A Vim Statusline from Scratch 人类第一颗原子弹爆炸始末 Distributed Training in PyTorch with Horovod Learning Expect Programming Essential Knowledge about SSH Nifty LaTeX Techniques -- Series 1 更改 Adsense 邮寄地址,重新寄送 PIN
Merging Branches with Git Rebase
2022-03-07 · via jdhao's digital space

When merging branches, the most direct way we can use is to git merge. However, with git-merge, the commit history and graph will be messy if there are a lot of branches.

We can also use git rebase to merge branches to make the commit history cleaner. Suppose we have a feat branch and master branch, and they share a common base commit.

-----A------B----C------D(master)
             \
               \---E---F (feat)

To merge the two branches using git-rebase, run the following command:

git checkout feat
git rebase -i master

Note that after running the above step, we may get merge conflict. We need to fix the conflict, then use git add some_file to mark that conflict for some_file has been resolved. Use git rebase --continue to fix conflict in other files, or finish the rebasing process (when there is no conflict anymore).

After the above step, we have the following commit graph:

              (master)
---A------C------D------E'---F'(feat)

In order to move master to tip of the commit, we can run the following command:

git checkout master
git merge --ff feat

The -ff option for git-merge will ascend the master to the same commit as the feat branch.

---A------C------D------E'---F'(feat)
                             \
                              \(master)

To delete the feat branch, run the following command:

Now, you have succeed in merging the two branches using git rebasing.