Git sheet list (Except basic Git)
1. Git for delete branch
$ git branch -d featureMain
Deleted branch
(branch name)(branch name)
2. Git for force checkout
$ git branch -f featureMain
ignore all code change branch
featureMain (branch name)
3. Git for put specific file
This can for update specific file too, this like cherry-pick but just pick some file from other branch
$ git checkout origin/develop -- Main/Config/dev.xcconfig $ git checkout origin/develop -- Home/HomeViewCOntroller.Swift
4. Git for Specific checkout commit
Example:
$ git checkout 62c34cc$ git checkout 6a4f3dc2
$ git branch To see list branch in your repo$ git branch -v To see last commit on each branch
$ git add -A stages all changes $ git add . stages new files and modifications, without deletions (on the current directory and its subdirectories). $ git add -u stages modifications and deletions, without new files
Git Version 1.x
Command | New Files | Modified Files | Deleted Files | Description |
---|---|---|---|---|
git add -A | ✔️ | ✔️ | ✔️ | Stage all (new, modified, deleted) files |
git add . | ✔️ | ✔️ | ❌ | Stage new and modified files only in current folder |
git add -u | ❌ | ✔️ | ✔️ | Stage modified and deleted files only |
Git Version 2.x
Command | New Files | Modified Files | Deleted Files | Description |
---|---|---|---|---|
git add -A | ✔️ | ✔️ | ✔️ | Stage all (new, modified, deleted) files |
git add . | ✔️ | ✔️ | ✔️ | Stage all (new, modified, deleted) files in current folder |
git add --ignore-removal . | ✔️ | ✔️ | ❌ | Stage new and modified files only |
git add -u | ❌ | ✔️ | ✔️ | Stage modified and deleted files only |
Source: https://stackoverflow.com/questions/572549/difference-between-git-add-a-and-git-add
Source: https://git-scm.com/docs/
7. When running git rebase get error "fatal : No rebase in progress?"
$ git add . $ git rebase --continue fatal: No rebase in progress?
When I forget to git push -f origin branch/name after rebase, for fixing that I need commit in terminal to undo git pull origin branch/name this code below.
$ git reset --soft HEAD~1
9. Cherry-pick
My code was save by cherry-pick when in my office use rebase to tracking progress but cannot use
"git pull branch" so this help me to solve that
- Old branch push to github (feature/old)
- Next I'ill create new branch from master ( git checkout -b feature/new)
- after that pick some commit from (feature/old) use cherry-pick
$git cherry-pick dg1234a7 // I use this for pick one commit from other branch // and add to my branch
- and that how cheery-pick save my code from 1000x rebase :D
note git:
-f = force
-d = delete
-b = branch
-u = ?
-v = ?
-A = all
if you know what mean in that question mark comment below
No comments: