Last active
September 1, 2018 11:19
-
-
Save amusameh/a22a3e64636314b2375c621884a3f19d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| git config --global user.name abdalsamad | |
| git config --global user.email abdalsamad.y.m@gmail.com | |
| git config --global core.editor "code --wait" | |
| git config --global -e | |
| # how to ues less\ | |
| Tips for using less on the command line. | |
| To navigate: | |
| f = for next page | |
| b = for previous page | |
| To search: | |
| /<query> | |
| n = next match | |
| p = previous match | |
| To quit: | |
| q = to quit | |
| ############################# | |
| # show the tree of the whole directory | |
| tree .git | |
| ##################333 | |
| cat .git/HEAD => show where the Head points | |
| ###################### | |
| # create hello.txt and add 'Hello World to it' | |
| echo 'Hello World!' > hello.txt | |
| Replace the hello.txt content with the 'Hello World!' | |
| echo "This is a test of the emergency git-casting system." >> hello.txt | |
| Append new text to the current file | |
| # show the type of the object at this SHA1 | |
| git cat-file -t 43388f | |
| git cat-file -p 43388f | |
| ############################# | |
| git ls-files -s | |
| git add <file> | |
| git rm <file> | |
| git mv <file> | |
| ############### | |
| add specific part of the file to commit | |
| git add -p | |
| git add -i => Todo: Need more poking around!!!!! | |
| ############## | |
| git diff => Shows file differences not yet staged | |
| git diff --staged => Shows file differences between staging and the last file version | |
| git diff --word-diff => word by word diff | |
| git diff [first-branch]...[second-branch] => Shows content differences between two branches | |
| ##############3 | |
| stashing | |
| ######### | |
| git stash pop throws away the (topmost, by default) stash after applying it, whereas git stash apply leaves it in the stash list for possible later reuse (or you can then git stash drop it). | |
| This happens unless there are conflicts after git stash pop, in this case, it will not remove the stash, behaving exactly like git stash apply. | |
| Another way to look at it: git stash pop is git stash apply && git stash drop. | |
| ######## | |
| git stash => stash changes | |
| git stash save "stash name message" => naming a stash for easy reference | |
| git stash --include-untracked => stash the untracked files | |
| git stash save -u | |
| git stash --all => Danger!!! use with caution (keep all files even ignored ones) | |
| git stash pop => apply the changes of the last stash and remove it(deosn't remove if there is a merge conflict) | |
| git stash pop stash@{1} | |
| git stash drop => remove the last stash | |
| git stash drop stash@{n} => remove the nth stash | |
| git stash clear => Reomve all stashes | |
| git stash branch <optional stash/branch??!! name> => start a new branch from a stash | |
| git checkout <stash name> -- <file name> => DANGER!!(will override the changes on working or staring area) Grab a specific file from a stash | |
| git stash list => list all stashes | |
| git stash show stash@{0} => show specific stash | |
| git stash apply => apply the last stash | |
| git stash apply stash@{0} => apply a specific stash | |
| git stash -p => advance interactive stash like git add -p | |
| ################################################ | |
| ################## TAGS #################### | |
| ################################################ | |
| git tag -a v1.0 -m "Version 1.0 of my blog" => create annotated tag | |
| git tag => list all the tags | |
| git show-ref --tags => list all tags and what commits they are pointing to | |
| git tag --points-at <commit> => list all tags pointing at a commit | |
| git tag show <tag-name> => show all details about specific tag | |
| ################################################ | |
| ############# Detached/Head ################ | |
| ################################################ | |
| =>create a new branch that points to the last commit you made in a detached state since the last commit refernce the others | |
| git branch <new-branch-name> <commit> | |
| git show-ref --heads => show where each head points | |
| ################################################ | |
| ######### Merging and Rebasing ############# | |
| ################################################ | |
| git merge --no-ff => prvent fast forward (retain the history even if no changes happend to the base branch) and create a merge commit | |
| git config rerere.enabled true => enable rerere for the current project | |
| git config rerere.enabled ture --global => enable it globally | |
| ################################################ | |
| ################# Loging ################### | |
| ################################################ | |
| git --no-pager log --oneline | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment