user2771324
user2771324

Reputation: 483

git push does not push latest commit to remote

git push does not push latest commit to remote.

Steps to reproduce:

  1. With a local project, last commit amended a few times before push.
  2. Create a new empty project. (in gitlab)
  3. Add the new project origin.
  4. git push -u [origin] [branch].

Problem:

git keeps push outdated commit to remote! Not the commits I locally amended before push.

How can I force git to cleanup and don't remember the stale commits?

Added Information: git 2.1.0

Upvotes: 2

Views: 1562

Answers (1)

VonC
VonC

Reputation: 1324887

git branch shows detached state

That would explain why pushing a branch to any remote would push an "outdated" commit: the branch still refer to the old commit, while the new amended commit (referenced by HEAD) is detached from any branch.

You can force a branch to reset to the current HEAD

git branch -f master HEAD

That would reset the branch master to the current amended commit.

Then you can create a new Gitlab repo, and git push -u origin master.

Upvotes: 2

Related Questions