Pressing commit in git when the local repo has not merged with the beginning of HEAD

Suppose my local repository is currently one fixer behind the source code. Suppose I commit a change in my local repository that does not contradict the original. How can I push this change to the origin without transferring / changing the changes from the source?

+3
source share
3 answers

Good, so that you deviate for persistent push-push, and you have reasons not to want to pull the latest update from the remote. I think you need to separate your changes.

So, let's create a branch at the common point HEAD ~ n in your case HEAD ~ 1:

git branch myfeat HEAD~1

Then drag forward:

git checkout myfeat
git merge master

Now the new branch has a common point, so just:

git push origin myfeat

:

--X---X--X--Xbug      (master)
          \
           \--Xfeat   (myfeat)

/ . , , , .

+3

, , , :

git pull --rebase
git push

( ) .

0

Perhaps he just wants to press the remote to have a backup of his changes, if so, he can do it with

git push origin HEAD:refs/heads/some_branchname_not_in_use

I usually use trash/somebranchnamefor these things to make it obvious in purpose.

0
source

All Articles