I\'m new to GitHub. Today I met some issue when I was trying to push my code to GitHub.
Pushing to git@github.com:519ebayproject/519ebayproject.git
To git@gi
If you are certain that no one made changes to your git repository and that you are working on the latest version, git pull
doesn't make sense as a solution in your heart...
Then this is probably what happened, you used git commit --amend
It lets you combine staged changes with the previous commit instead of committing it as an entirely new snapshot. It can also be used to simply edit the previous commit message without changing its snapshot.
ATLASSIAN tutorial: rewriting history
However, it is not recommended to perform git commit --amend
if you have already pushed the commit to GitHub, this is because "amending doesn’t just alter the most recent commit—it replaces it entirely. To Git, it will look like a brand new commit" which means to other developer on your GitHub, history looks like A->B->C but to you it looks like A->B->D, if GitHub let you push
, everyone else will have to manually fix their history
This is the reason why you get the error message ! [rejected] master -> master (non-fast-forward)
, if you know that no one has pulled your latest change, you can do git push --force
, this will alter the git history in your public repo. Otherwise...you can perform git pull
, but I believe this will have the same result as you didn't go through git commit --amend
,it will create a new commit (ie: git history after git pull: A->B->C->D)
for more detail: How to change your latest commit