

Git rebase from remote fork repo
source link: https://gist.github.com/ravibhure/a7e0918ff4937c9ea1c456698dcd58aa
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

In your local clone of your forked repository, you can add the original GitHub repository as a "remote". ("Remotes" are like nicknames for the URLs of repositories - origin is one, for example.) Then you can fetch all the branches from that upstream repository, and rebase your work to continue working on the upstream version. In terms of commands that might look like:
Add the remote, call it "upstream":
git remote add upstream https://github.com/whoever/whatever.git
Fetch all the branches of that remote into remote-tracking branches, such as upstream/master:
git fetch upstream
Make sure that you're on your master branch:
git checkout master
Rewrite your master branch so that any commits of yours that aren't already in upstream/master are replayed on top of that other branch:
git rebase upstream/master
If you don't want to rewrite the history of your master branch, (for example because other people may have cloned it) then you should replace the last command with git merge upstream/master. However, for making further pull requests that are as clean as possible, it's probably better to rebase.
If you've rebased your branch onto upstream/master you may need to force the push in order to push it to your own forked repository on GitHub. You'd do that with:
git push -f origin master
You only need to use the -f the first time after you've rebased.
Recommend
-
59
r/git:
-
97
-
17
在使用git作为源代码管理工具的时候,开发的时经常会面临一个常见的问题,多个commit 需要合并为一个完整的commit提交。 在一个基本的迭代周期里,你会有很多次commit,有跟配置文件相关的,有跟代码相关的,甚至有跟下次发布fixbug相关的。这些都是你在...
-
19
Interactive Git Tutorials – Rebase and Bisect Interactive Git Tutorials Following on from my earlier post on practising grep, this post shows...
-
10
Avec Git rebase, vos arbres poussent droitAvec Git rebase, vos arbres poussent droit Fri 16 September 2011 Le problème Par défaut, un git pull est équivalent à git fetch et git merge. Les merge, c'est bien pour l...
-
17
How to update a forked repo with git rebase – Git Many times you might came across to update/sync your forked repository with main repo. There are multiple ways but below one is very efficient way to sync your forked rep...
-
12
聊下git pull --rebase 有一种场景是经常发生的。 大家都基于dev...
-
9
How to do a git rebase 03 Dec 2015 How I do the git rebase: checkout master and fetch the latest stuff: $ git checkout master $ git pull
-
18
原文网址:http://yanhaijing.com/git/2020/09/23/git-rebase-merge/ rebase是git中一个神奇的命令,可以让并...
-
12
git tags and pushing to a remote repo Tags are useful to mark specific versions or releases of your code in a repo on a given branch. To tag everything on the current branch, use: git tag new-tag-name
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK