HEAD -> Local current position
origin -> The remote URL, hence a reference to the Git remote host
~ -> Ancestor ~3 or 3 times ~ -> 3 commits before
^ -> Parent n°1 commit
git branch -a # ls all branches
git checkout -b [name_of_your_new_branch] # Switch to branch
git push -u origin [name of this new branch] # Pushing it to origin
git branch -d <branch> # Delete ( actually not really )
# See a file as he is in an other branch
git show branch:file # Branch could be origin/something
git status -s # Short status
git commit -am "Message" # Add all and commit with message
###
git add -p <file> # 'Patch' -> Start hunk manual staging
# 'y' / 'n' -> stage / not stage
# 's' option will split the hunk if he's too big
git add -i # Interactive mode to have a menu for actions then selecting files, diff ...
git reset <commit n°, optional> <file> # Unstage file
git reset # Unstage all files
###
git checkout -- <file> # Discard changes on file
git checkout -- . # Discard all changes on '.' location
# Go to the branch where you want the other branch to be merged in
git merge [branch I want to merge] --comit
# See conflicting files
git diff --name-only --diff-filter=U
git log # List of commits with details
git log -S <some words> # Search all commits that have added or deleted <some words>
Unique bookmarks in history
git tag <tag name> <commit n°, optional> # Tag HEAD or specific commit number
git tag -d <tag name> # Delete
:Gstatus -> Interactive git status
Ctrl+n -> Next file
Ctrl+p -> Previous file
Also works in visual mode for multiple lines
Enter -> Open file
minus -> Toggle Add(stage) / Reset(unstage) file
cc -> :Gcommit -> Commit window like git commit without '-m'
p -> "Patch" = Start staging hunks in a lousy way, prefer following method :
q -> Quit status
Open a file and :Gdiff in it
:Gedit : -> Open index version of file (:0 for current)
:Gdiffsplit -> Mapped to :Gdiff -> Open diff tool
:diffoff -> Quit diff wiew
Can still run :Gstatus which will bring a new pane up top
:ls -> Get buffers #
:diffupdate -> Re-evaluate for instance for white lines
:diffget -> Get the diff from other window ; In merge, used in working copy
-> do -> In 2 way
:diffput <bufspec # if merge> -> Put the diff to other window ; In merge, used in //2 and //3
-> dp -> In 2 way
With Visual mode I can specificly select and write diffget or diffput
With '|' I can chain vim commands, for instance I can run an update after a get or put
[c -> Previous hunk
]c -> Next hunk
:only -> Select only current split -> Will finish the merge resolving
:Gwrite -> Will finish, select only current pane and stage the changes In working copy, otherwise if I only want to keep the changes in merge and stage that I can go on merge or target and do :Gwrite!
index version | working copy |
---|
:Gread -> In 2-way will replace the current buffer by the other -> Dicard if focus on working copy
:Gwrite -> In 2-way will replace the other buffer by the current buffer -> Stage if focus on working copy
target (HEAD) | working copy | merge |
---|---|---|
bufspec //2 | file name | bufspec //3 |
:0Glog -> Browse previous revision of current file
Optional arguments
-- -> Browse commit messages instead
-x -> x last revisions
--reverse
--until=yesterday
--since= -> "yesterday", "2 days" ...
-- -> Load all commits into the quickfix list
-- % -> Load all commits that affected the current file into the quickfix list
:copen -> List of revisions (enter to open)
:cnext -> Next version ( older )
-> ]q
:cprev -> Previous version ( newer )
-> [q
:cfirst
-> [Q
:clast
-> ]Q
:Gedit -> Without argument -> Go back to working copy
:Ggrep <opt, branch / sha> -> Search for pattern inside files included in git project or branch or commit
:Glog --grep= -- -> Search in commit messages
:Glog -S<pattern> -- -> Search added or removed text Yes no space after the S
Same :copen "QuickFix" system as above