A very basic question regarding GIT:
how can i delete all commits that were not yet pushed to the remote repository on a way that my modifications on my files will remain?
A very basic question regarding GIT:
how can i delete all commits that were not yet pushed to the remote repository on a way that my modifications on my files will remain?
git reset --soft origin/master
The command moves HEAD
back to the origin branch but preserves working repository.
Can you try this?
git log --oneline
git reset --soft COMMIT
where COMMIT
is the latest commit that was pushed to the remote repository.
If you really want to delete the commits, then you need to remove the objects from the key value store.
This can be done by first resetting the branch to the commit before you added any commits.
git reset --soft <COMMIT-SHA>
The --soft flag will keep your working directory. I'm assuming that the templates you are referring to is located somewhere in your working directory?
Typically the COMMIT-SHA will be pointed to by origin/master, if not the find it by doing
git log --oneline
or an equivalent.
When this is done you need to prune the repository.
Here is an answer which explains how
Basically you need to:
git reflog expire --expire-unreachable=now --all
git gc --prune=now
There is not really any reason to do this because eventually git will do this automatically.
Trying to understand, we need more details about your question.
You want:
It's not your answer, just a tip: use branches.