Reputation: 1012
I'm new to Git. I've successfully pushed and merged two commits. But when I check the git status, it still says that
$ git status
# On branch master
# Your branch is ahead of 'origin/master' by 2 commits.
#
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
no changes added to commit (use "git add" and/or "git commit -a")
Output after git push
(***
is company Git server address, which is ignored below):
$ git push
Total 0 (delta 0), reused 0 (delta 0)
remote: Processing changes: refs: 1, done
To ssh://***
! [remote rejected] master -> refs/for/master (no new changes)
error: failed to push some refs to 'ssh://***'
Does somebody know why?
Upvotes: 1
Views: 564
Reputation: 116197
Error message mentioning refs/for/master
suggests that you are pushing to Gerrit code review server. While Gerrit is fully compliant Git server, it has special rules to follow.
Please refer to Gerrit documentation on how to properly submit code reviews.
Probably even better idea would be to ask your company's Git/Gerrit admin on how to upload your commits properly.
In any case, note that changes you upload to Gerrit will not become official (and will not move origin/master
branch) until they are approved by someone using Gerrit web interface.
Once approved in Gerrit, you should be able to see changes when you do git fetch
(or repo sync
) next time.
Upvotes: 1
Reputation: 418
Just read the rest of the post. The problem is one of two:
There are files either not committed or not added*
When a new file is created and you commit @ the command line it does not automatically add them as it does in the git extensiosn UI. You need to add all (or some) i.e. git add --all (or some path and file(s))
Your local repository is not synced with the remote (origin). Do fetch and merge or pull before you push. (If you have files that haven't been added stopping you from doing a merge you will get another error. Just make sure all files are added, then merge from origin and all should work)
Upvotes: 0