Skip to content

Instantly share code, notes, and snippets.

@ivankisyov
Last active October 17, 2018 07:32
Show Gist options
  • Save ivankisyov/7302088cd320d6169a1c5f117005ca1f to your computer and use it in GitHub Desktop.
Save ivankisyov/7302088cd320d6169a1c5f117005ca1f to your computer and use it in GitHub Desktop.
Git

Git

Configuration

.gitconfig

[alias]

st = status
lg = log --oneline --all --decorate --graph
ad = add --all
br = branch -a

[color]

ui = true

git config --global core.autocrlf false

Branching

Create local branch from a remote branch

git checkout -b feature origin/feature

Delete local branch

git branch -d [branch-name]

Remotes

git remote add origin [repository url]

git push -u origin master

Cloning without creating an additional directory

git clone origin-url .

the dir into which you're cloning must be empty

Amending

git commit --amend -m “New commit message”

---> Add/remove/modify files from your last commit

git commit --amend --no-edit

Stash

// create stash item(will not stash untracked files!)
git stash save {"useful label goes here"}

// stash untracked files!
git stash save -u {"useful label goes here"}

// show list of stashed items
git stash list

// apply changes from a specific stashed item
git stash apply stash@{1}

// apply changes from the last stashed item and remove it from the stash list
git stash pop

git stash show

// remove the last stashed item from the stashed items list
git stash drop

// remove all stashed items from the stashed items list
git stash clear

Working with uncommited files

// revert modified files to the last commit state
git reset --hard

How to remove local (untracked) files from the current Git working tree?

https://stackoverflow.com/questions/61212/how-to-remove-local-untracked-files-from-the-current-git-working-tree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment