1

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

miatech
  • 2,150
  • 8
  • 41
  • 78
  • What do you expect to happen? Have you tried running `git pull` to bring your local git repository up to date? – Blender Feb 14 '18 at 00:14

2 Answers2

0

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.

Vikram Hosakote
  • 3,528
  • 12
  • 23
0

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.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250