git pull - merge remote changes before pushing again

ssc*_*rus 4 git github

I have recently changed my programming machine, which is leading to some startup issues in getting my new coding source to integrate seamlessly with my existing Github repo and my app on Heroku.

I originally used git clone to clone the Github repo onto my new machine. Since then, something has happened.

  • When I do git add ., git commit -m "mychanges", and git push, the code gets sent straight to Heroku. It used to get sent to my own Github repo, but I understand that's a simple matter of redefining what is considered 'origin'.
  • After redefining origin to my Github repo's address, and typing git push origin master, I get the following error:
    error: failed to push some refs to 'git@github.com:...'
    To prevent you from losinghistory, non-fast-forward updates were rejected. Merge the remote changes ('git pull') before pushing again.

I am concerned that my last two days of coding will be lost if I do a git pull (I have backed everything up just in case).

My current idea: do the git pull and manually update the last two days' files from my backup, then finally do my git push. Is this the right way to go, or is there a more elegant solution?

Zep*_*dio 10

除非您使用重置,否则git不会覆盖您的数据.git pull将接受提交origin/master(假设您的分支是主人)并尝试快速转发您的本地分支到那一点,合并任何本地更改.如果您已在本地提交,并且这些提交旨在追踪服务器上的任何更新的提交,则可以git pull --rebase改为.