Add notes on git reset

This commit is contained in:
Marcello 2021-05-20 12:21:48 +02:00
parent 2528d00f7c
commit c30e9d807c

View file

@ -85,7 +85,7 @@ def load_reference(name_or_id):
### Create Repository ### Create Repository
`git init [<project_name>]`: initialize a brand new Git repository and begins tracking `git init [<project_name>]`: initialize a brand new Git repository and begins tracking
`.gitignore`: specify intentionally untracked files to ignore `.gitignore`: specify intentionally untracked files to ignore
### Config ### Config
@ -188,28 +188,28 @@ Its generally recommended creating annotated tags so it's possible to have al
### Branching And Merging ### Branching And Merging
`git branch`: shows branches `git branch`: shows branches
`git branch -v`: show branch + last commit `git branch -v`: show branch + last commit
`git branch <branch-name>`: create new branch `git branch <branch-name>`: create new branch
`git checkout -b <branch-name>`: create a branch and switches to it, same as `git branch <name>; git checkout <name>` `git checkout -b <branch-name>`: create a branch and switches to it, same as `git branch <name>; git checkout <name>`
`git branch`: show list of all existing branches (* indicates current) `git branch`: show list of all existing branches (* indicates current)
`git checkout <branch-name>`: change current branch (update HEAD) and update working directory `git checkout <branch-name>`: change current branch (update HEAD) and update working directory
`git branch -d <branch-name>`: delete specified branch `git branch -d <branch-name>`: delete specified branch
`git branch -m <old_name> <new_name>`: rename a branch without affecting the branchs history `git branch -m <old_name> <new_name>`: rename a branch without affecting the branchs history
`git merge <branch-name>`: merges into current branch `git merge <branch-name>`: merges into current branch
`git merge --continue`: continue previous merge after solving a merge conflinct `git merge --continue`: continue previous merge after solving a merge conflinct
`git mergetool`: use a fancy tool to help resolve merge conflicts `git mergetool`: use a fancy tool to help resolve merge conflicts
`git rebase`: rebase set of patches onto a new base `git rebase`: rebase set of patches onto a new base
`git rebase -i`: interactive rebasing `git rebase -i`: interactive rebasing
`gitk`: show graph of history (git for windows only) `gitk`: show graph of history (git for windows only)
### Undo & [Rewriting History](https://www.themoderncoder.com/rewriting-git-history/) ### Undo & [Rewriting History](https://www.themoderncoder.com/rewriting-git-history/)
`git commit --amend`: replace last commit by creating a new one (can add files or rewrite commit message) `git commit --amend`: replace last commit by creating a new one (can add files or rewrite commit message)
`git commit --amend --no-edit`: replace last commit by creating a new one (can add files or rewrite commit message) `git commit --amend --no-edit`: replace last commit by creating a new one (can add files or rewrite commit message)
`git reset HEAD <file>`: unstage a file `git reset HEAD <file>`: unstage a file
`git reset <commit>`: undo all commits after specified commit, preserving changes locally `git reset <commit>`: undo all commits after specified commit, preserving changes locally
`git checkout <file>`: discard changes `git checkout <file>`: discard changes