0

I am contributing to a public repo. I cloned the repo and created a new branch cmd_addons. I wanted to commit a few changes after some days but my changes are getting rejected. These are the steps that I have followed: (Assuming I am on the cmd_addons branch)

1. git pull upstream master && git push origin master
2. git add 'somefile'
3. git commit -m "..."
4. git push origin cmd_addons

This keeps throwing error Updates were rejected because your current branch is behind its remote counterpart. Integrate the remote changes After this I tried git pull but it says that everything is upto date.

PS: I already looked at this issue and this one. I am unable to understand what is the correct way of doing it without losing anything.

enterML
  • 2,110
  • 4
  • 26
  • 38
  • How did you create the `cmd_addons` branch? Please include the steps. – Tim Biegeleisen Mar 10 '19 at 07:22
  • `git pull origin cmd_addons` might be what you need to do here. – Tim Biegeleisen Mar 10 '19 at 07:23
  • You're describing two *remotes* named `origin` and `upstream`. That implies there are three *repositories* involved, but you only mention two of them ("public repo" and "cloned"). I'm guessing here that there was an in-between step, "fork public repo to GitHub repo" (based on the github tag). We now need to know what you're doing with your `cmd_addons` branch in *your* repo (on your machine) and with the `cmd_addons` branch in the GitHub repo that you control (but that is not *your* repo). – torek Mar 10 '19 at 07:26
  • In general, you cannot git push to repo unless repository owner granted you push permission (rare!). For GitHub repositories, usually you should create pull request - basically put your changes for review and ask repository owner to merge them. – mvp Mar 10 '19 at 07:30
  • `git pull origin cmd_addons` This worked. Thank you – enterML Mar 10 '19 at 07:32

0 Answers0