I made fixes and tests, git commit -a
, updated my branches and now I'm trying to push to a GitHub fork I had previously made:
vagrant@rails-dev-box:~/rails$ git push mine my_fix
Username for 'https://github.com': myusername
Password for 'https://myusername@github.com':
To https://github.com/myusername/rails.git
! [rejected] my_fix -> my_fix (non-fast-forward)
error: failed to push some refs to 'https://github.com/myusername/rails.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again. See the
'Note about fast-forwards' section of 'git push --help' for details.
I'm guessing the reason for this issue is the fork is a little outdated (by a week maybe). I've made other pushes to the fork though that I don't want to lose. What do I do here?
I think your branch is not up-to-date so you need to pull recent change then push your changes to remote.
$git pull --rebase branch_path
$git push remote_name branch_name
Your (Github) fork know nothing about upstream changes
Message states clearly
Merge the remote changes
ie - in your Github repo you have changesets , that are not in the local repo
While on a master
branch locally:
git remote add upstream git://github.com/rails/rails.git
git pull --rebase upstream master
git push --force origin master
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.