reset and merge

Nathaniel Ngo
Jan 29 · 2 min read

git reset

Returns the repository to a certain state

git reset [-q] [<tree-ish>] [ — ] <paths>…​

This resets index entries for all paths to the state specified in tree-ish. git reset <paths> performs the reverse operation of git add <paths>.

git reset(--patch | -p) [<tree-ish>] [ — ] [<paths>…​]

Chunks from the diff between the index and tree are applied in reverse to the index. git reset -p performs the reverse operation of git add -p.

git reset [<mode>] [<commit>]

Resets current branch head to the specified commit


Resets head to commit, but does not alter index file or working tree


Changed files are preserved but not staged for commit. It also resets the index


Modifications to tracked files are discarded and resets index


Resets index and updates files that are updated between commit and HEAD


Updates files in working tree different between commit and HEAD

git merge

Joins commits that have diverged together into the current branch

When merge conflicts occur, git merge --abort can be run to attempt to reverse the merging process, but if there were uncommitted changes when the merge was initiated, this may not work. git merge is not recommended with sizable changes because merging can be difficult to revert in the event of a conflict.

git merge --continue can also be only run after a conflict.