1

I'm new to git and I have a github repository where I want to commit changes to a python file and push . However after accesing my repository from an ubuntu vm now that I am back to windows 10 when I want to push I get

error: failed to push some refs to 'https://github.com/BillSkentos/MovieFlix2020_E17136_SKENTOS_VASILIS.git'

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.

I'm completely new to git and tried git checkout master and tried pushing but to same result . I would appreciate your help with this . Thank you in advance

Vasilis Skentos
  • 506
  • 11
  • 22
  • You need to perform ```git pull``` as there are changes in the remote that you do not have. It states so in the message : ```hint: 'git pull ...') before pushing again.``` – tomerpacific Jun 28 '20 at 09:32
  • @tomerpacific I just typed git pull and got Auto-merging webservice.py CONFLICT (content): Merge conflict in webservice.py Automatic merge failed; fix conflicts and then commit the result. – Vasilis Skentos Jun 28 '20 at 09:33
  • That means that the local changes you have made are causing a code conflict with the changes in the remote repository. Either fix them locally or stash them locally and apply them after pulling. – tomerpacific Jun 28 '20 at 09:36
  • @tomerpacific Could you provide an example ? I'm new to git and find it hard to create the command you say – Vasilis Skentos Jun 28 '20 at 09:39
  • @See [here](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/resolving-a-merge-conflict-using-the-command-line) and [here](https://stackoverflow.com/questions/161813/how-to-resolve-merge-conflicts-in-git). – tomerpacific Jun 28 '20 at 09:46
  • @tomerpacific I did git add webservice.py then commited then pushed succesfully .I am still in master/rebase 1/1 however – Vasilis Skentos Jun 28 '20 at 09:46
  • Your problem is a normal problem that occurs very often when you use git. That's part of the normal workflow. So I think it can't be solved through asking questions and you'd better read a quick start tutorial on how to use git or pair with another developer to learn how to use git... – Philippe Jun 28 '20 at 10:16

1 Answers1

2

In Git 1.7.0 and later, you can checkout a new branch

git checkout -b <branch>

Edit files, add and commit. Then push with the -u (short for --set-upstream) option:

git push -u origin <branch>

Git will set up the tracking information during the push. Now by using these commands , you will not get any error.

Tushar Jain
  • 134
  • 1
  • 12