Rollback to remote origin/master, but list all files that have changed first
My local repository is 5 commits ahead of the remote origin master.
I have large files that I put in g开发者_运维知识库it by mistake, and I think its going to be a mess to get those out.
So, how can I reset to the remote origin master?
Also, before doing that, I want to just get a list of all the files that are different from my local repo versus the remote master (so I know which files to edit once I rollback to the remote master)
You can get the unwanted commits out by doing a
git rebase -i origin/master
now mark the commits that added the large files with an "e" for edit. Save and quit. Now you will be prompted to go to that commit, unstage the large files, and then
git rebase --continue
You should now have a clean history that you should be able to push.
Hope this helps.
You could reset your HEAD to point to what origin/master is pointing at right now and also get the files unstaged. Now you can redo the commits the way you wanted to. Either as separate commits by using multiple git add, git commit, or like below, create one squashed commit, without the large content that you previously added:
$ git reset --mixed origin/master
$ rm -rf folder/with/large/files/
$ git add .
$ git commit -m "Squashed commits and removed unwanted large files"
It's not exactly what you asked but this seems like a good solution for your problem :
I would checkout the commit where the large files where commited amend it and rebase master on the amended commit.
git diff --stat master..origin/master
will get you the changed files and git reset --hard origin/master
will roll you back. If you've never played with reset before, and if you might want to get at some of those changes in master, its simplest to set a temporary tag on your current master commit, git tag temp
, so you can find it easily after the reset. Later you can delete it.
If you just want to remove the accidentally added files, use rebase
as @adymitruk said.
精彩评论