I\'m getting that error with a PR, but when I git status
it says nothing to commit, working directory clean
.
That\'s on the branch with the PR.
git status
tells you about the state of your working directory tree and your index (where staged changes live) relative to the latest commit on the current branch. The output you're seeing means that the files on your disk exactly match the latest commit on your branch. That is, there's "nothing to commit".
The message from GitHub is not about committing, but about merging. GitHub would like to offer you a one-click method to merge this branch into your master
branch, but it can't, because that merge results in conflicts. Since GitHub doesn't have a way to help you resolve conflicts though the website, it asks you to resolve them on your own machine.
The best way to deal with this situation is to merge the current master branch into your topic branch locally and then push the result to GitHub. To do that, do the following:
$ git checkout pr12 # If you're not already on pr12
$ git fetch origin
$ git merge origin/master
(I'm assuming that the GitHub remote is called origin
. It typically is, and you probably know if it isn't.)
First we make sure we're on the right branch. Then we make sure we have the latest code from the master
branch on the GitHub repo. Then we merge that code into our pr12
branch.
Remember: git fetch origin
updates our local origin/master
to be the same as GitHub's master
, but it doesn't touch the local branch called simply master
. We'd have to checkout our master
branch to make changes to it. Instead, we just update our idea of what's on GitHub (origin/master
) and merge that into our pr12
.
When you run the merge
command, you'll see conflicts. Those represent decisions that git (and GitHub) couldn't make automatically. Edit those files so they're the way you want them to end up. Then:
$ git add each/file.txt that/had/conflicts.conf
$ git commit # Your editor will open with a pre-filled
# commit message. Just save and close the file.
$ git push origin pr12
That is, we add the versions of the files that we fixed, then finish the merge commit we started with git merge
. Lastly, we push the branch with the new merge commit up to GitHub.
Since we've resolved the conflicts, this branch should be trivial to merge the other way, into master
. GitHub will notice that, and give you a green "Merge" button.