I have just recently moved from Gerrit to GitHub and am currently figuring out a fitting workflow. My workflow at the present is as following:
start
--- a (master, origin/master)
Create branch and make changes
--- a (master, origin/master) --- b (new_branch)
git add .
git commit
git push --set-upstream origin new_branch
--- a (master, origin/master) --- b (new_branch, origin/new_branch)
if ( new_branch is fine ) => merge origin/new_branch to origin/master and delete origin/new_branch
git branch -D new_branch
git remote prune origin #clean merged origin branches as for some reason it still appear at local
git checkout master && git pull
--- a --- b (master, origin/master)
if (new_branch is NOT fine) => edit new_branch
git add .
git commit --amend
--- a (master, origin/master) --- b (origin/new_branch)
\
--- c (new_branch)
at here, for some reason I can't just git push --set-upstream origin new_branch
to push the change upstream
so I have to do a git pull --rebase
at this step, I have to do an excessive rebase which marks ALL of my new changes as conflicts even when they could just merge to nothingness, for example: just add a return; onto a blank line would make
it become
<<<<<<< HEAD
=======
return;
>>>>>>> [demo_bazel] add dummy test
after the excessive rebase:
--- a (master, origin/master) --- b (origin/new_branch) --- c (new_branch)
only then I can finally do git push --set-upstream origin new_branch
again
--- a (master, origin/master) --- b --- c (new_branch, origin/new_branch)
My goal is, if possible, how can I make all of the changes I make on new_branch stays on only 1 node, always? that means the last line would be without the b in between:
--- a (master, origin/master) --- c (new_branch, origin/new_branch)
the reason here is that I wouldn't want all the useless b nodes to bloat my git tree, in Gerrit they used to stay neatly and effortlessly in 1 git node above the master node by doing git push ${1-origin} HEAD:refs/for/master%r=reviewer
after creating a git commit --amend
.
I have described all of my currently working status on the above as it's a part of the question
I've found the solution for the problem above
for the following edits after the first commit, just use the below to push new changes to the remote branch:
git push --force-with-lease