Search code examples
gitgit-commitgit-push

How to sync only my latest commit with git?


My local repository is ahead of remote by 2 commits - commit A and commit B.

Commit A was made first, and contains a very large file by accident, which is too large to stage and is causing a failure on push.

So, I deleted the file, untracked it, and then made commit B. However, I cannot push commit B, because then both commit A and B are attempting to push, which leads to commit A causing the same failure before B can be pushed.

Is there any way to tell git to ignore the first of these two commits? Or to "delete" commit A?


Solution

  • Maybe you can reset all commits and start again, with a clean stack.

    • git reset --soft HEAD~2 and then git commit -am "cleaned commit".