-2

I worked in a project on my desktop and pushed it in master branch. Now i am working on my laptop with same project by downloading it in my laptop. After making some changes i want to marge this to my Github repository. But says an error which is

error: failed to push some refs to 'https://github.com/mahfuz380/loginsystem' hint: Updates were rejected because the tip of your current branch is behind hint: its remote counterpart. Integrate the remote changes (e.g. hint: 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details.

nkr
  • 3,026
  • 7
  • 31
  • 39
Al Mahfuz
  • 11
  • 4
  • "hint: Updates were rejected because the tip of your current branch is behind hint: its remote counterpart. Integrate the remote changes (e.g. hint: 'git pull ...') before pushing again." – Geno Chen Mar 06 '19 at 06:20
  • Possible duplicate of [Cannot push to GitHub - keeps saying need merge](https://stackoverflow.com/questions/10298291/cannot-push-to-github-keeps-saying-need-merge) – phd Mar 06 '19 at 10:33
  • https://stackoverflow.com/search?q=%5Bgit%5D+Updates+were+rejected+because+the+tip+of+your+current+branch+is+behind – phd Mar 06 '19 at 10:33

3 Answers3

3

Please follow the below steps when you try to push changes to remote branch.

  1. First save your local changes using git stash command

    git stash
    
  2. Pull the changes from remote branch

    git pull 
    
  3. Unstash your previously stash changes using below command

    git stash apply
    
  4. Push your changes to remote branch

    git push origin 
    

If you encountered any conflicts once you unstash the changes then please resolve the conflicts manually and then push.

Hope it helps!

KZapagol
  • 888
  • 6
  • 9
0

git pull first before you push. You might have to undo your changes first.

gosuto
  • 5,422
  • 6
  • 36
  • 57
0

As the message hinted, you should pull first to merge the changes, and push to remote.

git pull origin master
git push origin master