Reputation: 40778
I got a problem when trying to push a new change from my local repository to GitHub. First, I did a
git commit -a
, and then git push origin master
. Which gave me error:
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to '[email protected]:user/repo.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again.
So I figured there had been changes in the GitHub repo since my last pull and I then did git pull origin master
which worked fine, but when I now do git push origin master
I get:
From github.com:user/repo
* branch master -> FETCH_HEAD
Already up-to-date.
But the the new file I added is not showing up on GitHub. It is still present in my local repo though. When I try type git commit -a
, it says:
nothing added to commit but untracked files present
and git branch -v
gives:
* master 525fad2 Merge branch 'master' of github.com:user/repo
Upvotes: 0
Views: 598
Reputation: 31
If you do a git status you should see something similar to this:
` On branch develop
Untracked files: (use "git add ..." to include in what will be committed)
bb1.c
nothing added to commit but untracked files present (use "git add" to track) `
So you would need to do a git add bb1.c to first add the file for tracking before doing your commit.
Upvotes: 1
Reputation: 12385
It may have been stashed when you did your pull.
Try
git status
To see what is going on and look if its stashed
git stash show
If it is stashed you need to apply it
git stash apply
Use apply instead of pop as apply leaves the stash around for easy re-try of the apply, or for looking at, etc If it is stashed then look at https://stackoverflow.com/a/19003191/21063 for a more compreshesive explanation.
Upvotes: 1