How do I rebase a chain of local git branches?
Suppose I have a chain of local git branches, like this:
master branch1 branch2
| | |
I pull in an upstream change onto the master branch:
Now I rebase branch1, giving me this:
Note that because of rebasing branch1, commits A and B have been rewritten as A' and B'.
Here's my problem: now I want to rebase branch2. The obvious syntax is
git rebase branch1 branch2, but that definitely does not work. What I want it to do is just reapply C and D on top of branch1, but instead it tries to reconcile A and A' and it considers them conflicting.
This does work:
git rebase --onto branch1 branch2^^ branch2
This assumes I know that branch2 has exactly 2 commits beyond the previous branch1 ref.
git rebase --onto works, is there a 1-line git command that will rebase branch2 on top of a newly-rebased branch1, in a way that I don't have to know exactly how many commits were part of branch2? (I want to specify some magic ref instead of branch2^^ for the middle argument.)
Or is there some other approach I'm overlooking?
I would be most interested in a solution that scales well to extreme cases, not just two branches - suppose I've got something more like 5 local branches, all chained on one another, and I want to rebase all of them together.
So, yesterday I posted a question regarding some weird conflicts when I tried to rebase an upstream branch into my local topic branch. In the end I used git rebase --merge upstream and solved a lot of
If I'm automating the checkout of a branch, the pulling of that branches changes, and the fetching and rebasing of that branch onto another branch through a shell script, I can often encounter errors
I would like to see all the branches on my local environment. what flag should I add/eliminate in this command: git log --graph --oneline --all I mean: How should I modify the git command so I will
I was working on my local branch doing some changes and when I finished I pushed everything to the remote brach. Before merging the branch with develop I thought I should do a rebase cos the other guy
I managed to create a little mess in my local git repository. I was trying to fix a broken commit by using the following instructions. Before running the git commit --amend (and after the git rebase
How can I differentiate between two local branches in git ? How can I copy one local branch to another local branch ? In general how can I perform difference operation between two local branches on m
I understand that if I have a branch ready to merge with remote master, I need to do: git checkout 'my branch' git rebase master (rebase because I want simple history + my changes are minuscule enoug
With git remote prune origin I can remove the remote branches that are not any more on the remote. But I want to remove also those local branches that were created from those remote branches (a check
I am learning git. In this book I read that rebase is not safe when I pushed commits into public repository. It is clear. But what if I didn't pushed commit-X, but created local branches After commit-
I have imported from SVN into Git, now I have one big branch, like this: work on feature C work on feature B work on feature C work on feature C work on feature B work on feature A I want separate f
I have the following situation: I made some commits to my local repository, and then a huge merge of another branch (~150 commits) into the master - it had a lot of conflicts in it. Now, I want to mov
I want to do an interactive rebase so I: git rebase -i HEAD~5, but I'm getting more than five commits. Why could it be?
New to git. A bit confused about how some of it works, conceptually. So it sounds like, in terms of local work, its a good idea to have a branch that contains only what goes into production and anoth
I want to change the last commit content. I can do local changes. and then execute git commit --amend I can also do the following: git rebase -i HEAD~ choose the commit to edit. do local changes and
I encountered a strange situation with git in which I had a feature branch that modified some files and deleted one file foo.js. When I rebased onto master via git rebase master feature, I encount
If I run git rebase -i HEAD~10 The editor comes up with just git://github.com/jquery/jquery.git Instead of the commits. What am I doing wrong here?
I was wondering if this is possible to propagate rebase of the branch. Let's consider the following setup: branchA *-*-*-*-*-*-<*> \ branchB *-*-*-* \ branchC *-*-*-* If there are some change
I have a local branch work, where I created two new files a.py, b.py and committed them. Then, instead of doing git rebase origin/master, I accidently typed git rebase origin master, and now the c
How do you delete local files from your current branch?
I am working with 3 branches and I want to rebase one branch from two others at the same time. What I got with git log --graph --decorate --pretty=oneline --abbrev-commit are the followings: Branch
I have cloned a svn branch using git-svn and am tracking all folders and branches. I would like to drop everything and only track web/trunk/* (for rebase, dcommit, etc.) Is there any way to do this wi
by now, I know that there is a nice way how to combine commits and change the commit message by using 'git rebase --interactive' Having the following situation: $ git rebase --interactive HEAD^^^^ pic
What is the correct way to make the remote branches/tags that exist after a git-svn init/git-svn fetch into local Git branches/tags before pushing to my remote Git repo and abandoning SVN altogether.
I am working on a svn project with two branches, lets call them trunk branches/foo My idea is to clone the whole svn repository (telling git which folder are trunk, tags and branches), do the merge i
I'm using git-svn to manage a Subversion repository using git. I usually have a large number of git branches at any one time. I often need to update them to match the latest code in the repository, bu
I'd like to be able to make local (never tracked, never committed) files stick to certain git branches. For example, I'd like to be able to do something like: $ git checkout version1.0 $ make $ ./my
being new to git, I have this dumb question - what is the correct way of using feature-branches ? From what I have gathered, this is how I thought it should be used: got some 'develop' branch from whi
I have a project with a handful of submodules. Many of them are cloned from a GitHub fork to which I've added a branch for my custom mods. A typical setup is like thus: In local folder: MyProject1/Fra
After a rebase failed with a conflict, I could not continue the rebase using a Git GUI client. When performing git rebase --continue on command line (msysgit 1.7.4), it opened a text editor. After ha
How can I list any local branches that appear (as per .git/config) to be tracking remote branches that no longer exist? Remote branches are on GitHub in this case but I suspect their location has no r
I'd like to use git rebase so as to cleanly merge a feature in the master branch (in less commits or at least at the top of the change log). Note that I'm the only one working on the repository. After
I'm using the git flow tools and I've gotten myself in a bit of problem. My git branches have diverged. I've read master branch and 'origin/master' have diverged, how to 'undiverge' branches'? and hav
Context We use several git repositories with the same workflow, involving two branches, and are wondering how best to synchronize commits from one to the other. Put simply, our git repositories cont
When is it recommended to use git rebase vs. git merge? Do I still need to merge after a successful rebase?
I have a local branch for day-to-day dev work in git. My workflow is: Do stuff on local_branch, commit Fetch origin/master Rebase local_branch to catch up with new stuff from origin/master It all w
Relatively simple question but I can't find much on the internet. All my search results simply show how to use git branches but doesn't explain how its different. I know that with SVN, creating a new
I am rebasing in git and am encountering many conflicts. I address each one and do git rebase --continue, only to be met with the next conflict. How can I see how close I am to successfully completing
Our version control manager recommends us to use git pull --rebase to pull new changes from upstream branch. I want to use EGit (Eclipse plugin for git) to execute that. How can I do this?
I understand conceptually that a branch I create in my local GIT repository must be configured to track a specific branch on a remote GIT if I expect the commands like pull to work without specifying
I have a problem when I try to do a git svn rebase on my repository. It displays : Checksum mismatch: code/app/meta_appli/app_info.py expected: d9cefed5d1a630273aa3742f7f414c83 got: 4eb5f3506698bdcb64
I have a doubt related to creating patches and rebase them into master branch. For example: I'm working in a separated branch from master and I generated 5 commits of change. So, I want to send this c
I've cloned a remote repository which has several branches, worked on one of those branches, committed the changes and pushed. After a time interval during which colleagues have modified the remote re
This question: Git - How to push a locally-create branch Received a +1 comment: It looks like the remote repository has been configured not to allow you to push new branches. Now, I created the remo
I would like to fetch all branches from the remote and then rebase my current branch on any changes to the master branch. To do this, for some reason, I need to first checkout master, pull, and then
I am developing using git but I have to publish via svn. That's why I've set up git-svn (by git svn clone). My usual workflow is like this: git svn rebase # get local git repository up-to-date git add
Is it possible to somehow chain archetypes together by some super-archetype in Maven? For example I have an archetype create a multi-module project setup. One of these module projects should be create
A---B---C topic / D---G master Say I have the above branch structure in git. If I do git checkout topic followed by git rebase master, from what I've experienced, I will have to resolve conflicts for
While working with git-svn, and a 'typical' svn repo /trunk, /branches/..., /tags/... How do I push a local branch to a new branch inside of /branches ?
I'm trying to understand ... What's the difference between git merge and git rebase?
When I use the git branch command, it displays only one local branch: master However, when I use the git branch -a command, it displays the initial master branch as well as two remote master branches: