Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit / JGit » Auto-create change-branch when pushing to gerrit
Auto-create change-branch when pushing to gerrit [message #1818276] Wed, 11 December 2019 10:21 Go to next message
Felix Dorner is currently offline Felix DornerFriend
Messages: 392
Registered: December 2015
Senior Member
Hi,

I often have 2 or more independent changes on a local branch that I want to push to gerrit individually. I first cherry pick change 1, and push to gerrit. I then reset, cherrypick change 2 and push to gerrit. Then I lose track of all but the last change that I pushed. I can "fetch from gerrit..." to get them all back, but I wonder if Egit could do this automatically, i.e. create the gerrit branche automatically after I push a change?

Felix
Re: Auto-create change-branch when pushing to gerrit [message #1818284 is a reply to message #1818276] Wed, 11 December 2019 13:03 Go to previous messageGo to next message
Matthias Sohn is currently offline Matthias SohnFriend
Messages: 1268
Registered: July 2009
Senior Member
I think the better approach is to develop independent changes in separate branches based on the
upstream branch you are aiming for (most often this is origin/master).

We could add a cherry-pick command to cherry-pick a selected commit to a new branch in one step.

A more crazy idea could be to add a command to cherry-pick commits which were done on the same branch
onto separate new branches based on the same upstream branch. We could generate branch names
based on the respective commit's commit message subject or ask the user how to name those branches.

E.g. if you have

c4 <---- branch foobar -- HEAD
|
c3
|
c2
|
c1 <---- origin/master
|
...

the command would create

HEAD
|
foobar c3branch c2branch
| | |
c4 c3 c2
\ | /
\ | /
c1 <---- origin/master
|
....

not sure how such a command should be named, maybe "disentangle" ?
Looks like an additional command in interactive rebase [1]
in addition to the existing commands pick, edit, squash, fixup, drop

[1] https://git-scm.com/docs/git-rebase#_interactive_mode
Re: Auto-create change-branch when pushing to gerrit [message #1818321 is a reply to message #1818284] Thu, 12 December 2019 13:31 Go to previous message
Thomas Wolf is currently offline Thomas WolfFriend
Messages: 576
Registered: August 2016
Senior Member
Interesting workflow. Felix, why do you reset? You could also create a new branch then. I presume you have something like the chain c2, c3, c4 Matthias showed, and then you do
git checkout -b for_pushing origin/master
git cherry-pick c2
git push origin HEAD:refs/for/master
git reset --hard HEAD^1
git cherry-pick c3
git push origin HEAD:refs/for/master
git reset --hard HEAD^1
git cherry-pick c4
git push origin HEAD:refs/for/master

Why not
git checkout -b c2branch origin/master
git cherry-pick c2
git push origin HEAD:refs/for/master
git checkout -b c3branch origin/master
git cherry-pick c3
git push origin HEAD:refs/for/master
git checkout -b c4branch origin/master
git cherry-pick c4
git push origin HEAD:refs/for/master

?
Previous Topic:Can not open worktrees
Next Topic:Failing to upload repo to github using eclipse 201912 -SSL protocol_version
Goto Forum:
  


Current Time: Fri Mar 29 11:03:53 GMT 2024

Powered by FUDForum. Page generated in 0.02763 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top