Reputation: 1180
While working on some files, I have created a backup file to each one, but I forgot to erase them before pushing and rebasing. I have committed multiple times since but haven't pushed it yet.
Here were my steps:
git add -A
git commit -m <message>
git checkout master
git pull upstream master
git push
git checkout "branch"
git rebase master
My current branch doesn't have the backup files anymore. Would it be enough to just push and rebase master with my updated branch?
Upvotes: 0
Views: 29003
Reputation: 5617
If you have a commit pushed then you can delete the files directly and then do:
git add .
git commit --amend --no-edit
git push origin <your branch name> -f
This will push the changes without generating a new commit.
Upvotes: 4
Reputation: 10640
What you could do is to do a soft reset, delete the files, then commit and push.
git log
to find the hash of the commit immediately before you added the filesgit reset --soft <hash>
(inserting the hash of the commit)Delete any unwanted files
Stage and commit all files.
This will however squash all of the commits that you have made to your branch to a single commit. If this is acceptable to you, then it would be all that you would need. If you would want to preserve all of your commit history, then you could create a new branch before you added the files, then cherry pick the commit that you added the files, but delete the unwanted files before you make the commit, and then commit just the files you wanted to update. After you do this, you can cherry pick any other commits to that branch as well then push.
Upvotes: 4