I am working on a remote server that does not have my git credentials, and I want to pull from master. I have no local commits, I just want to update the local repository on this machine to match the remote repository (origin). Using this answer I managed to update the repository:
my_repo$ git pull https://my_user@github.com/my_repo
Password for 'https://my_user@github.com':
<some updates....>
Indeed, after this action, the local repository was updated to include all the commits exactly as on the remote repository.
But, for some reason I cannot fathom, the local repository became ahead of master, and I can't find a way to fix it. How is that possible???
my_repo$ git status
On branch master
Your branch is ahead of 'origin/master' by 3 commits.
(use "git push" to publish your local commits)
nothing to commit, working tree clean
my_repo$ git push https://my_user@github.com/my_repo
Password for 'https://my_user@github.com':
Everything up-to-date
my_repo$ git status
On branch master
Your branch is ahead of 'origin/master' by 3 commits.
(use "git push" to publish your local commits)
nothing to commit, working tree clean
my_repo$ git pull https://my_user@github.com/my_repo
Password for 'https://my_user@github.com':
From https://github.com/my_repo
* branch HEAD -> FETCH_HEAD
Already up to date.
Also, when I use git log
I see this strange outcome, that corresponds to my branch being ahead of master, but does not correspond to "reality":
my_repo$ git log --pretty=oneline
09ee1f2 (HEAD -> master) Latest commit on master
b6433fb Another commit from master
31da031 Another commit from master
85b95ae (origin/master, origin/HEAD) Another commit from master which was the head before pulled
Anyone has any advice on how to fix this? And any thoughts on how this happened and how I can avoid this in the future?
Thanks!