Skip to content

Instantly share code, notes, and snippets.

@antontit
Last active July 11, 2018 21:12
Show Gist options
  • Save antontit/5f6e91cfc0ec18f70f648f800bf0f785 to your computer and use it in GitHub Desktop.
Save antontit/5f6e91cfc0ec18f70f648f800bf0f785 to your computer and use it in GitHub Desktop.

Branches

git branch -v
git checkout feature

new branch & checkout

git checkout -b fix

Uncompleted changes

if the files are not indexed, then delete the changes

git checkout -f master
[fix branch]git stash -> checkout master -> checkout fix -> git stash pop

manual movement

[master branch] git branch fix 
git checkout fix
git branch -f master 54a4

or

git checkout -B master 54a4

git

git

rollaback

git branch -f master fix

Detached HEAD

git checkout 1913

ad to branch(master)

git cherry-pick 9e28

git

Rollback file to old commit version

git checkout 54a4 index.html

reset in index

git reset index.html

Commit

if file indexed

git commit -m "message changed" message.txt

reset in index

git reset index.html

rollback file

git checkout -- index.html -> index
git checkout HEAD -- index.html -> repository

git

Start

Create global config file

$XDG_CONFIG_HOME/git/config

git config --list
git config --unset user.email 
git config --remove-section user

config editor

git config --global -e

crlf and lf

git config core.autocrlf

.gitattribues

* text=auto

editors

git config --global core.pager 'less -RFX'
git config --global core.editor "subl -n -w"

aliases

git config --global alias.ac '!git add -A; git commit -m'

check ignore

git check-ignore -v build/index.css  

File ignore

git config --global core.excludesFile ~/.gitignore
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment