Skip to content

Instantly share code, notes, and snippets.

@Reactiver
Last active January 22, 2020 07:09
Show Gist options
  • Save Reactiver/ec5d7f81203ac95e4ca83b05b7dcecd9 to your computer and use it in GitHub Desktop.
Save Reactiver/ec5d7f81203ac95e4ca83b05b7dcecd9 to your computer and use it in GitHub Desktop.
@ === HEAD
.git/ORIG_HEAD - save the last commit hash after merge
git branch BRANCH_NAME - create new branch
git branch BRANCH_NAME [COMMIT_HASH || EXIST_BRANCH] - create branch on commit with COMMIT_HASH or on exist branch
git branch -d BRANCH_NAME - delete branch
git branch -D BRANCH_NAME - delte branch(force)
git branch BRANCH_NAME COMMIT_HAST - reset deleted branch
git checkout COMMIT_HASH || BRANCH_NAME - checkout to this commit
git checkout -f HEAD - reset all changes in current branch
git checkout -B BRANCH_NAME COMMIT_HASH - switch branch to commit
git checkout COMMIT_HASH [PATH_TO_FILE] - update file to COMMIT_HASH state
git checkout PATH_TO_FILE === git checkout HEAD PATH_TO_FILE
git checkout -- PATH_TO_FILE - (--) implicitly indicates that this is the path
git checkout - === git checkout @{-1} - checkout to previous branch
git stash - save changes and reset uncommited files
git stash pop - return saved changes
git log - print history of commits
git log --oneline - minimal version of git log
git log BRANH_NAME - print all commits in branch
git reflog === git log --oneline -g - show reference log for HEAD
git reflog --no-decorate - print reflog wihtout decorate data
git show COMMIT_HASH || BRANCH_NAME - print info about commit with diffs
git show --quiet - print only commit info without diffs
git show COMMIT_HASH:PATH_TO_FILE - show file in commit
git show COMMIT_HASH:/WORD_FROM_DESCRIPTION - show last commit with some description
git gc - garbage collector
git gc --prune=now - delte all unrachable commits
git tag TAG_NAME COMMIT_HASH - add tag to commit
git tag -n - show all tags with commit message
git tag -a -m 'ANNOTATION MESSAGE' TAG_NAME COMMIT_HASH - add tag with annotation
git commit -C COMMIT_HASH - copy author and date for current commit
git commit -C COMMIT_HASH --reset-author - copy without author
git commit --amend - add changed files to new commit with previous commit data
git commit --amend --no-edit - without opening editor
git commit --amend --reset-author - add current author of commit
git reset === git reset HEAD - purge index
git reset PATH_TO_FILE - reset file
git reset COMMIT_HASH PATH_TO_FILE - update only index to file in commit
git reset --keep - hard reset with save changed files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment