I\'ve made kind of a big refactoring in my project: I renamed files, removed, added... Besides, I added some folders in .gitignore. However, I\'ve already made a commit to a
UPDATE
If you have deleted the .git
folder (not a great idea), you can create a new clone of the repo and move your stuff to that, and continue there. Something like this
cd ..
git clone new-repo
rm -rf new-repo/* // this will not remove new-repo/.git
cp -f new-repo
cd new-repo
Then continue as below.
Note that it is better if you can restore the .git
folder. Creating a new repo will loose all local repo information you had in the original local repo, like local branches that were never pushed.
END UPDATE
You could
git reset --soft HEAD^
git add -A .
git commit -m "rewriting history"
git push --force origin master
This will back up to the previous commit (while preserving the working tree and index), commit your changes, and then force push that rewritten history to the remote.
push --force
is dangerous stuff. It will disturb others who have already pulled, and is considered very rude, but if no one else have started work on it, that is not a problem.
This is what is happening:
--- A -- B master
^
|
origin/master
git push
--- A -- B master, origin/master
git reset HEAD^
git commit -am "rewriting"
--- A -- B origin/master
\
\
B' master
git push --force
--- A -- B
\
\
B' master, origin/master