Binoj123
Binoj123

Reputation: 103

error when github pull command using

When work with github I have already maintain my local repo and always push them to master when changes happen. But I have to use branch to commit some issue recently. So I make a branch naming issue number.

git checkout -b 1

Then add all changes and commit them to new branch(branch no 1) Then I closed issue from origin in github repo using pull request and merge with master branch.

Suddenly I want to add some changes to master branch and swiched to master using,

git checkout master

Then I add changes and commit them. After that try push them using,

git push origin master

But its not work and error, "you should pull them first". Then I pull using,

git pull

But when pulling its come some error "not merged origin with local repo "

How can I solve those problem merge local repo with Origin(github) and push my present changes?

Upvotes: 3

Views: 61

Answers (1)

andrybak
andrybak

Reputation: 2349

After pull request is merged, the github has following in master:

---*--...--A--M
    \        /
     *---P--R

Where A was the last commit on master branch before merge, P and R are the commits on the branch no 1, and M is the merge of the pull request.

At that time you want to make changes on top of master, but forget to pull the master, so your local master is:

---*--...--A

You do some work on top of A:

---*--...--A--B--C

You try to push, get an error, if you do git pull --rebase here, you will get:

---*--...--A--M--B'--C'
    \        /
     *---P--R

Where B' and C' are rebased versions of B and C respectively. Now you can push this to github.

You can use git pull --rebase to apply your changes on top of the merge of that pull request into the master.

Upvotes: 2

Related Questions