There are two remotes assigned, origin
is used to pull the changes and harmeet
is the production.
I tried git reset --hard
but as soon as I pull latest changes the status reverts to master | MERGING
and then I can't push latest code to harmeet
because Git tells me everything is up to date. I am not sure what is wrong here.
As mentioned in @Holger's comment, you can do git merge --abort
to abort the merge. However, you might not want to do that. The merge happens because the remote (origin
) has changes that you don't have locally. Your history might look something like this:
*--*--A--B--C [master, harmeet/master]
\
D--E [origin/master]
(Note that master
== harmeet/master
. I'll come to that in a minute.)
There are three solutions: merge, rebase, or force update.
The easiest solution would be to just complete the merge. To do so, resolve any conflicts in your editor, stage with git add .
, and commit with git commit
. Your history would then look like this:
*--*--A--B---C [harmeet/master]
\ \
\ F [master]
\ /
D--E [origin/master]
and then you can git push origin master
to update origin
and git push harmeet master
to update harmeet
.
If you want to keep a linear history, abort the merge and then do:
git pull --rebase
(If there are any conflicts, resolve them and continue with git rebase --continue
.)
Your history would then look like this:
*--*--A--B--C [harmeet/master]
\
D--E [origin/master]
\
B'--C' [master]
You can then update origin
with:
git push origin master
and force-update harmeet
with:
git push --force-with-lease harmeet master
Your final history would then be:
*--*--A--D--E--B'--C' [master, origin/master, harmeet/master]
If you really don't want the changes from origin
, you can do:
git push --force-with-lease origin master
and your history would look like this:
*--*--A--B--C [master, harmeet/master, origin/master]
If Git tells you that harmeet/master
is up-to-date, then it is at the same commit as your local master
, unless someone has pushed to harmeet/master
since your last fetch.
If your goal is to get the changes from origin
(commits D
and E
) to harmeet
, then you'll need to either rebase or merge, and then push, as described above.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With