user2424531 user2424531 - 1 month ago 5x
Git Question

how to remove unneccesary files already committed before git push

Let me explain the issue here :-

1) I created a new branch :

git checkout -b <newbranch>

2) I modified file1.tcl in this branch and committed it (no push done till now)

3) Now i had to work on another 2 separate files and i should have created a separate branch for it but mistakenly i started working on the same
and committed both that files too (file2.tcl and file3.tcl) from this same branch

4) so realising my mistake at this point I created a new separate branch and did my changes (they were few only) to file2.tcl and file3.tcl from here and committed them and even did a git push. so now the required changes for file2.tcl and file3.tcl are in place and pushed to github

5) Now coming back to
, As I want to push the changes done in file1.tcl from here , the problem is I can see that if i push now along with file1.tcl ...file2.tcl and file3.tcl will also go in PUSH. So I somehow want to take those 2 files out of my git-push stack

gourabm@lb4b13-pc-01(eRx)$ git diff --stat --cached origin/master
eRx/lib/file1.tcl | 3348 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------------------------------------------------------
eRx/bin/file2.tcl | 1 -
eRx/lib/file3.tcl | 75 +++---
3 files changed, 1978 insertions(+), 1446 deletions(-)

Please suggest me an easy and safe way to take these 2 files out of my git-push list so that they dont go in the push and only one file1.tcl goes in the push


have you tried

git revert {commit-that-changed-file2.tcl}
git revert {commit-that-changed-file3.tcl}
git commit -m "undoing extra changes"

from my understanding git should undo the changes in just those commits and allow you to re-commit with those changes before push, so your remote should remain unaffected.