Reputation: 795
when I try to push to master im getting error
https://github.my.corp/i64444/app.git ! [rejected]
HEAD -> refs/for/master (non-fast-forward) error: failed to push some refs to 'https://github.my.corp/i64444/app.git' hint: Updates were rejected because a pushed branch tip is behind its remote hint: counterpart. Check out this branch and integrate the remote changes hint: (e.g. 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details.
I read the following post Cannot push to GitHub - keeps saying need merge and try to do the git push -f origin master which doesnt help , I got message that everyting is up to date , any idea?
I did also before git reset --hard origin master (fetch & rebase also)which doesnt help either...,any idea?
The output of the pull
* branch master -> FETCH_HEAD
Already up-to-date.
The output of the git status is:
HEAD detached from ea82585
Untracked files:
(use "git add <file>..." to include in what will be committed)
.idea/
nothing added to commit but untracked files present (use "git add" to track)
The number ea82585 is the number of the latest commit in the master...
Upvotes: 1
Views: 1355
Reputation: 5514
From your git status
output:
HEAD detached from ea82585
It seems that you have checked out a commit instead of a branch. Thus git is unable to track your current commit to a remote branch. Once you enter what is called a detached head state git will be stuck at a commit and thus do nothing when you pull or push. Check out this answer for more details on detached head.
If git is able to track your local branch to your remote repository, you will see git status output as something like:
$ git status
On branch dev
Your branch is up-to-date with 'origin/dev'.
How to fix it
Essentially you will have to move your commits to a branch that Git can track. You can do this by:
git commit -m "....."
git branch my-temporary-work
git checkout master
git merge my-temporary-work
Copied from this answer
Upvotes: 2