How to git rebase using the hash instead of the branch name?
What is sure:
- a
git rebase
(not agit-svn rebase
) can accept any valid commit as an argument, so hash values will work. - The caveat section of
git-svn
does warn you of:
avoid all
git clone
/pull
/merge
/push
operations between git repositories and branches.
The recommended method of exchanging code between git branches and users isgit format-patch
andgit am
, or just 'dcommit’ing to the SVN repository.
So you need to make sure to not introduce commits in a SVN-synchronized branch which wouldn't know about that commit and would report as such.
(you have the opposite case in the SQ question "git svn
- <file>
was not found in commit <hash>
")
JJD
Android, Kotlin, Java, Git, Python, Ruby, Ruby on Rails, JavaScript, MacOS, Ubuntu #SOreadytohelp http://stackoverflow.com/10m
Updated on June 24, 2022Comments
-
JJD almost 2 years
I use
git rebase --onto target source foo
to move the branchfoo
from the branchsource
onto the branchtarget
. Do you know if it is possible to use hash values instead of branch names (if not given) like this:git rebase --onto ab91c f4242 foo
?
As a workaround I temporarily added branch names to the relevant commit objects. But this can be a pita if you have many branches to being rebased.Example situation:
° bb42a ° ab91c ° 979c2 /° fb648 foo ° f4242 -- ° 333c9
After
git rebase --onto ...
° bb42a /° fb648 foo ° ab91c -- ° 979c2 ° f4242 ° 333c9
Background:
The explained problem is very common if you use an svn-server as you remote repository. All you commit objects get rewritten since the svn-id will be added every time yougit svn dcommit
to the svn-repository. This detaches all other branches from their former master. -
JJD almost 13 yearsI probably did something wrong yesterday. Git rebase with hash values works. Thank you anyway.
-
VonC almost 13 years@JJD: excellent. It is always useful, as soon as any error message pops up, to copy both the command and the error message in some temp file text. It can come in handy in question like this one ;)