Reputation: 567
I have a commit tree with remote branches. Recently I've got a requirement to push changes from my master
branch to another remote branch origin_fsa/master
.
I added new remote origin_fsa
and fetched the remote branch from that remote and now it goes separate from the main commit graph. Like this (I use TortoiseGit):
I want to re-write everything on this newly added remote with my specific commit (no need to merge, no need to keep those commits on origin_fas/master
remote branch, maybe just hard rebase). But I don't know how to do it.
I want the origin_fsa/master
remote branch (blue line) to be on my current master on the picture.
Upvotes: 1
Views: 162
Reputation: 3111
By using TortoiseGit:
As you can see, it's:
push local branch "master"
to the remote branch "master"
on remote "origin_fsa"
with force (actually, it's "--force-with-lease" git option)
Be aware of that the force push may lose some commits on remote "origin_fsa" if you don't merge/rebase first.
Also see the tips of the know changes and unknown changes options:
(These tips will show up when moving the mouse on those options)
I'd recommend using known changes option first.
If not using force option, you may encounter this error:
git.exe push --progress "origin_fsa" master:master
To XXX/fsa.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'XXX/fsa.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Upvotes: 1
Reputation: 51810
To force push your local master
branch to the master
branch located on origin_fsa
:
git push -f origin_fsa master:master
Upvotes: 2