2

After I have pushed my files to master, I realise that, I need to add few more file. Obviously, I can add, make new commit and push it again.

But is it some how possible to overwrite older push? (May be deleting the last push; add, commit and push again?)

I am sure this is already answered, but I am possibly confused about what to look at! May be the link is sufficient(and duplicate).

BaRud
  • 3,055
  • 7
  • 41
  • 89
  • 2
    Possible duplicate of [How to modify a specified commit in git?](http://stackoverflow.com/questions/1186535/how-to-modify-a-specified-commit-in-git) – Andrew Marshall Sep 25 '16 at 15:05
  • 1
    The nearest to what you want to do is Jeff's answer. However, this is not really a push overwrite. To answer directly your question, no, it's not possible to delete a push. – autra Sep 25 '16 at 16:11

1 Answers1

1

do like you would make a new commit.

git add <file>

then pass the amend flag

git commit --amend

now you will have to force push to the remote

git push <remote> <branch> --force

WARNING: this will rewrite your history so others will need to force pull if they have already pulled the other commit

git fetch <remote>
git reset --hard <remote>/<branch>
Jeff Puckett
  • 37,464
  • 17
  • 118
  • 167