Git: Remove committed file after push

+1 vote

Is there a possibility to revert a committed file in Git? I've pushed a commit to GitHub and then I realized that there's a file which I didn't want to be pushed

Aug 14, 2018 in Git & GitHub by Nilesh
• 6,900 points
93 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes
  1. check out the previous (unchanged) state of your file; notice the double dash

    git checkout HEAD^ -- /path/to/file
    
  2. commit it:

    git commit -am "revert changes on this file, not finished with it yet"
    
  3. push it, no force needed:

    git push
    
  4. get back to your unfinished work, again do (3 times arrow up):

    git checkout HEAD^ -- /path/to/file
answered Aug 14, 2018 by Kalgi
• 36,220 points

Related Questions In Git & GitHub

0 votes
1 answer

How to forcefully commit a file to Git even if the file is ruled as unchanged?

This is simple, just follow the below ...READ MORE

answered Jul 11, 2018 in Git & GitHub by Sophie may
• 9,250 points
23 views
0 votes
1 answer

Is there a way to remove a directory from git repository?

This is simple, just follow the commands ...READ MORE

answered Jul 13, 2018 in Git & GitHub by Sophie may
• 9,250 points
22 views
0 votes
1 answer

How to give a file execute mode permissions in Git?

You can easily do this in one ...READ MORE

answered Aug 6, 2018 in Git & GitHub by Sophie may
• 9,250 points
81 views
+13 votes
2 answers
0 votes
1 answer
0 votes
3 answers

Change commit message after committing and before push.

You also can use git filter-branch for that. git filter-branch ...READ MORE

answered Sep 6, 2018 in Git & GitHub by lina
• 8,100 points
77 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.