Reputation: 550
I am getting a strange error when updating a forked repository. I already created a dev-branch in the forked repo(for my development work).
I have cloned a forked repo
git clone https://github.com/twbs/bootstrap
Check the current branch
git branch
*master
dev-branch
Change to dev-branch
git checkout dev-branch
make changes and commited them to dev-branch
git commit
Add remote url
git remote add parent [email protected]:twbs/bootstrap
when i do a git push now, i am getting error hint: Updates were rejected because the tip of your current branch is behind hint: its remote counterpart
So, I did
git fetch parent
git merge parent/master
A new commit screen is opened with commit message "Merge remote-tracking branch 'bootstrap/master' into dev-branch"
Still i get the same error, when I do git push
Now, I did
git pull
A new commit screen is opened with commit message "Merge branch 'dev-branch' of https://github.com/username/bootsrap into dev-branch
I don't know what has happened. Did i make a mistake somewhere ? Can someone point out to me the right steps to update and push from a different branch of forked repository ?
Upvotes: 1
Views: 436
Reputation: 14903
What version of git are you using? Older versions of Git used to default to "attempt to push all local branches to the remote", which is what it appears yours tried to do.
Newer versions of Git default to only attempting to push the currently checked out branch to a branch of the same name upstream (which I also dislike). I personally recommend git config --global push.default tracking
(or upstream in newer versions), which attempts to push your current branch to its upstream.
In your case, you had two branches, and it tried to push them both. Both were rejected because both were behind.
So no mistake on your part really, although if you prefer a linear history you might want to consider rebase instead of merge.
Upvotes: 1