User Tools

Site Tools


using_git

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
using_git [2019/04/26 10:55]
be.ing [Tutorials] credit xkcd comic
using_git [2020/01/19 17:28] (current)
hlzhs [Targeting another base branch]
Line 116: Line 116:
  
 To work on another bug or feature, [[#create a new branch]]. To work on another bug or feature, [[#create a new branch]].
 +
 +====== Targeting another base branch ======
 +Sometimes you [[#​create_a_new_branch|started your work]] from the wrong base branch. Maybe you wrote a bugfix or a controller mapping that should be merged into current stable release, but started from the ''​master''​ branch instead of the stable version'​s branch.
 +
 +In these cases you need to [[https://​git-scm.com/​book/​en/​Git-Branching-Rebasing|rebase]] your work on the correct branch. For example, the current stable version is 2.2.3 and you want your changes to be a part of the 2.2.4 release, but you based your work on ''​master'',​ you need to rebase onto the ''​2.2''​ branch.
 +
 +To rebase your work in the ''​fixing_some_bug''​ branch from ''​master''​ onto ''​2.2'',​ run:
 +<​code>​
 +git fetch upstream
 +git rebase --onto upstream/​2.2 upstream/​master fixing_some_bug
 +</​code>​
 +
 +Since this changes commits that you already pushed to the server, you need to use the ''​-f''​ flag when pushing the changes to the remote repository:
 +<​code>​
 +git push -f origin fixing_some_bug
 +</​code>​
 +
 +
 +If you already opened a PR, you need to [[https://​help.github.com/​en/​github/​collaborating-with-issues-and-pull-requests/​changing-the-base-branch-of-a-pull-request|change its base branch]]. ​
 +
  
 ====== Keeping up to date with upstream ====== ====== Keeping up to date with upstream ======
using_git.1556290538.txt.gz ยท Last modified: 2019/04/26 10:55 by be.ing