简体   繁体   中英

git push fails after using git mv

I am not sure if the reason that I am having my issue is because I used git mv but besides that, I have not done anything unusual with my branch (ie just committed some changes to files, including the ones that were git mv ed).

Running git status produces the message:

Your branch is ahead of 'remote/branch' by 2 commits.

(use "git push" to publish your local commits)

(Only name of remote/branch changed)

But when I try to git push , I get the error

daniel$ git push

To ssh://git@git.domain.com/repo

! [rejected] branch -> branch (fetch first)

error: failed to push some refs to 'ssh://git@git.domain.com/repo'

hint: Updates were rejected because the remote contains work that you do

hint: not have locally. This is usually caused by another repository pushing

hint: to the same ref. You may want to first integrate the remote changes

hint: (eg, 'git pull ...') before pushing again.

hint: See the 'Note about fast-forwards' in 'git push --help' for details.

I tried checking out the remote branch that I am trying to push to and looking at the log , but the latest commit is indeed two commits ago in the branch that I am trying to push (ie it seems like it should be a fast-forward merge).

Why could this be happening? Is it possible that git mv is somehow causing this to happen?

No. Someone else merely pushed work onto the branch you're working on before you did. So Git requires you to pull their work before you can push yours, to make sure you have a chance to resolve any conflicts before pushing.

git pull origin your-branch

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM