Examples of using Git reset in English and their translations into Greek
{-}
-
Colloquial
-
Official
-
Medicine
-
Ecclesiastic
-
Financial
-
Official/political
-
Computer
So, assume we run git reset file. txt.
For now this magic invocation is all you need to know about the git reset command.
If we run git reset master, develop itself will now point to the same commit that master does.
We would just run something like git reset eb43bf file. txt.
The git reset command is primarily used to undo things, as you can possibly tell by the verb.
Before moving on to more specialized tools,let's talk about the Git reset and checkout commands.
Calling git reset without an option is not dangerous- it only touches your staging area.
We go into closer detail on its relationship with git reset in Reset Demystified.
You can run git reset--soft HEAD~2 to move the HEAD branch back to an older commit(the first commit you want to keep).
We can move our branch back by using git reset as we saw in Reset Demystified.
While git reset can be a dangerous command if you call it with--hard, in this instance the file in your working directory is not touched.
This is also the default,so if you specify no option at all(just git reset HEAD~ in this case), this is where the command will stop.
Also, like git reset and git add, checkout will accept a--patch option to allow you to selectively revert file contents on a hunk-by-hunk basis.
In most cases, if you follow the errant git merge with git reset--hard HEAD~, this will reset the branch pointers so they look like this.
It is just like git reset[branch] file in that it updates the index with that file at that commit, but it also overwrites the file in the working directory.
This means if HEAD is setto the master branch(ie, you're currently on the master branch), running git reset 9e5e64a will start by making master point to 9e5e64a.
It would be exactly like git reset--hard[branch] file(if reset would let you run that)- it's not working-directory safe, and it does not move HEAD.
If for some reason you find yourself in a horrible state and just want to start over,you can also run git reset--hard HEAD or wherever you want to get back to.
We first effectively cover the simplest use of git reset in Unstaging a Staged File, where we use it to unstage a file we had run git add on.
We use git reset--hard to abort a merge in Aborting a Merge, where we also use git merge--abort, which is a bit of a wrapper for the git reset command.
If for some reason you just want to start over,you can also run git reset--hard HEAD, and your repository will be back to the last committed state.
Running git checkout[branch] is pretty similar to running git reset--hard[branch] in that it updates all three trees for you to look like[branch], but there are two important differences.
We first effectively cover the simplest use of git reset in 將已預存的檔案移出預存區, where we use it to unstage a file we had run git add on.