简体   繁体   中英

how to push changes to github from a different computer

I'm always coming across this error message when trying to push to github from a different workstation.

To https://github.com/zentech/techgeorge.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://github.com/zentech/techgeorge.git'
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: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

most of the time I work from different computers. (laptop/desktop) when I'm done and push my work. But when I move to my other computer. and I start making modifications. It asks me to fetch changes first before pushing to github

It asks me to fetch changes first before pushing to github

This is expected. Before pushing, pull and rebase (if you have any un-pushed local changes) so that you get the latest code from upstream. More info is here , here and here .

If it is a fork, sync ( fetch + checkout + merge ) your fork.

If you need to fetch all refs of all branches, do git pull --all .

But when I move to my other computer. and I start making modifications

Before making any modification, start with git pull .

Even if you have made some modification and/or commits, you can still do a git pull, provided you have done (once) first (as documented here ):

git config --global pull.rebase true
git config --global  rebase.autoStash true

That will fetch and then replay your local modification of top of the updated upstream 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