Compare commits

..

4 Commits
init ... main

Author SHA1 Message Date
e96f3eaa2e
Interactive rebase for all commits 2022-04-04 16:33:34 +03:00
ae290204ed Commit Ranges 2022-01-05 20:00:41 +03:00
33cc143bf2 git referencing using ^ and ~ 2022-01-04 22:13:23 +03:00
7c285cfdc3 README.md added 2022-01-03 19:40:22 +03:00

49
README.md Normal file
View File

@ -0,0 +1,49 @@
For advanced git commands training
You can make any training in test branch
## git reset
To make a commit you need to do 3 steps:
1. Make changes
2. Add them to staging area
3. Make a commit
```
git reset --soft # resets #3 only
git reset (--mixed) # resets #3 and #2
git reset --hard # resets all #3, #2 and #1
```
---
## git rebase
```
git rebase <hash> # rebase using commits's hash
git rebase -i HEAD~n # interactive rebase for last n commits
git rebase -i --root HEAD # interactive rebase for all commits
```
---
## git commit referencing using ^ and ~
```
~n # follows straight history in one branch
^ = ^1 # first parent
^n # n parent
^^^2 # first parent/first parent/second parent
```
To practice referencing checkout "merge" branch and use some command to see what commints are referenced.
```
git log --oneline -1 HEAD~4
git log --oneline -1 HEAD~4^2^
etc...
```
---
## Commit Ranges
```
git log --oneline range2..range1 # use git log for showing what commits are selected (reverse order)
git cherry-pick --allow-empty (HEAD)..range1 # copy all commits from range1 branch into current that are already merged
git cherry-pick --allow-empty range1 ^range2 # copy all commits that are in range1 but not in range2
```