Last active
April 29, 2019 20:49
Revisions
-
akottr revised this gist
Feb 6, 2015 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -324,6 +324,10 @@ git reset --soft HEAD~1 git reset --soft HEAD~2 ``` #### git protocol is blocked by company error message could be like this ``` Failed to execute "git ls-remote --tags --heads git://github.com/ ``` see http://stackoverflow.com/questions/4891527/git-protocol-blocked-by-company-how-can-i-get-around-that/10729634#10729634 ```bash git config --global url."https://github".insteadOf git://github -
akottr revised this gist
Feb 6, 2015 . 1 changed file with 5 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,5 @@ Git / Github basic commands =========================== Config ------- @@ -324,5 +323,8 @@ git reset --soft HEAD~1 # undo last two commits git reset --soft HEAD~2 ``` #### git protocol is blocked by company see http://stackoverflow.com/questions/4891527/git-protocol-blocked-by-company-how-can-i-get-around-that/10729634#10729634 ```bash git config --global url."https://github".insteadOf git://github ``` -
akottr revised this gist
Dec 10, 2014 . 1 changed file with 5 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -285,6 +285,11 @@ git branch -D develop-branch git push origin --delete develop-branch ``` #### clean working directory ``` git clean -xdf ``` #### Show tags ```bash git tag -
akottr revised this gist
Feb 13, 2014 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -17,9 +17,9 @@ git config user.name "username" git config user.email "[email protected]" ``` #### Show git branch in terminal `name@host ~/git/fun-stuff [master] $` ```bash # put this into the ~/.bashrc parse_git_branch() { git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/[\1] /' } -
akottr revised this gist
Feb 13, 2014 . 1 changed file with 9 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -17,6 +17,15 @@ git config user.name "username" git config user.email "[email protected]" ``` #### Show git branch in terminal `name@host ~/git/fun-stuff [master] $` ```bash parse_git_branch() { git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/[\1] /' } export PS1="\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \[\033[01;31m\]\$(parse_git_branch)\[\033[00m\]$\[\033[00m\] " ``` #### If cygwin ssl error occurs ```bash git config --global http.sslVerify false -
akottr revised this gist
Feb 13, 2014 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -174,7 +174,7 @@ git fetch git diff --stat --color master origin/master ``` #### fetch + merge + push ```bash # 1. Fetch from repo git fetch @@ -193,7 +193,7 @@ git commit -am "manual merge" # 7. push your changes to upstream git push origin master ``` #### pull + merge + push ```bash # 1. Pull from repo git pull -
akottr revised this gist
Feb 13, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -205,7 +205,7 @@ git commit -am "manual merge" git push origin master ``` #### pull + rebase + push ```bash git fetch git rebase -
akottr revised this gist
Feb 13, 2014 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -207,7 +207,6 @@ git push origin master ### pull + rebase + push ```bash git fetch git rebase # -> MANUAL MERGE <- @@ -217,7 +216,7 @@ git push ``` ```bash # long version (copied from intellij console) git push --progress origin master:master git fetch --progress --prune origin git rebase origin/master -
akottr revised this gist
Feb 13, 2014 . 1 changed file with 33 additions and 34 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -43,40 +43,6 @@ git remote -v git remote rename origin destination ``` Basic commands -------------- @@ -124,6 +90,39 @@ git log -10 --follow /my/directory/or/file git log -10 --color --stat ``` Basics ------ ### Areas changed -> staged -> commit (HEAD) ### Push ```bash git push origin local-name:remote-name ``` * You can never push when you are not on the lastest HEAD -> `(!rejected master -> master (fetch first))` * You have to do a 'pull + merge + push' or a 'pull + rebase + push' ### Pull 1. changes are in the changes area or in the staging area and there are conflicts * pull not possible. `error: Your local changes to the following files would be overwritten by merge. Please, commit your changes or stash them before you can merge` * do a commit or stash 2. changes are in commit area * no conflicts * automatic merge and commit with new commit message * conflict `CONFLICT (content): Merge conflict in README.md` * show all conflicts: `git diff --name-status --diff-filter=U` * merge the conflicts manual and commit 3. changes are stashed ```bash git stash git pull git stash pop # then merge conflicts by manual and commit ``` Repositories ------------ -
akottr revised this gist
Feb 13, 2014 . 1 changed file with 69 additions and 5 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -36,13 +36,47 @@ git remote set-url origin http://[email protected]/akottr/some-repo.git ```bash # 1. show remotes git remote -v # origin https://[email protected]/akottr/some-repo.git (fetch) # origin https://[email protected]/akottr/some-repo.git (push) # 2. rename git remote rename origin destination ``` Basics ------ ### Areas changed -> staged -> commit (HEAD) ### Push ```bash git push origin local-name:remote-name ``` * You can never push when you are not on the lastest HEAD -> (!rejected master -> master (fetch first)) ** You have to do a 'pull merge push' or a 'pull rebase push' ### Pull 1. changes are in the changes area or staging area and there are conflicts * pull not possible. error: Your local changes to the following files would be overwritten by merge. Please, commit your changes or stash them before you can merge * do a commit or stash 2. changes are in commit area * no conflicts * automatic merge and commit with new commit message * conflict * CONFLICT (content): Merge conflict in README.md * show all conflicts: `git diff --name-status --diff-filter=U` * merge the conflicts by hand and commit 3. changes are stashed ```bash git stash git pull git stash pop # then merge conflicts by hand and commit ``` Basic commands -------------- @@ -141,7 +175,7 @@ git fetch git diff --stat --color master origin/master ``` #### fetch + merge ```bash # 1. Fetch from repo git fetch @@ -160,7 +194,7 @@ git commit -am "manual merge" # 7. push your changes to upstream git push origin master ``` #### pull + merge ```bash # 1. Pull from repo git pull @@ -172,6 +206,34 @@ git commit -am "manual merge" git push origin master ``` ### pull + rebase + push ```bash git push git fetch git rebase # -> MANUAL MERGE <- git add . git rebase --continue git push ``` ```bash # long version (copied from itellij console) git push --progress origin master:master git fetch --progress --prune origin git rebase origin/master # -> MANUAL MERGE <- git add --ignore-errors -- README.md git rebase --continue git push --progress origin master:master ``` #### consolidate/merge commits. * @see http://stackoverflow.com/questions/7555800/pull-rebase-push-in-one-command-or-just-a-few ```bash git rebase -i HEAD~2 ``` Branches and Tags ----------------- #### show branches @@ -249,4 +311,6 @@ git reset --soft HEAD^ git reset --soft HEAD~1 # undo last two commits git reset --soft HEAD~2 ``` -
akottr revised this gist
Jan 23, 2014 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -53,7 +53,11 @@ git clone http://github.com/akottr/edu.git #### Add to staging area ```bash # add files (but does not remove files) git add . # add and remove files (removes deleted files, too) git add -A . # show status after add git status ``` -
akottr revised this gist
Jan 23, 2014 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -118,6 +118,8 @@ git diff git diff --cached # CHANGED vs HEAD git diff HEAD # HEAD vs HEAD-1 git diff HEAD^ ``` #### show diff -
akottr revised this gist
Nov 13, 2013 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -177,9 +177,11 @@ git branch -a ``` #### checkout branch ```bash git checkout -b origin/v0.9 # create branch and checkout branch git checkout -b experimental origin/v0.9 # READ ONLY checkout branch git checkout origin/v0.9 ``` #### push branch -
akottr revised this gist
Nov 12, 2013 . 1 changed file with 11 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -187,6 +187,8 @@ git checkout -b experimental origin/v0.9 git push <remote> <local branch name> # example git push origin develop-branch # if there already exist a tag with this name use the long format git push origin refs/heads/develop-branch:refs/heads/develop-branch ``` #### push from branch to origin/master @@ -220,6 +222,15 @@ git tag v0.9 git push origin --tags ``` #### push tag ```bash git push <remote> <local branch name> # example git push origin develop-tag # if there already exist a branch with this name use the long format git push origin refs/tags/develop-tag:refs/tags/develop-tag ``` Troubleshooting --------------- #### undo last commit -
akottr revised this gist
Nov 12, 2013 . 1 changed file with 7 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -182,6 +182,13 @@ git checkout origin/v0.9 git checkout -b experimental origin/v0.9 ``` #### push branch ```bash git push <remote> <local branch name> # example git push origin develop-branch ``` #### push from branch to origin/master ```bash git push <remote> <local branch name>:<remote branch to push into> -
akottr revised this gist
Sep 11, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -109,7 +109,7 @@ Diff and Merging ---------------- #### understanding diff Flow: `changed -> staged -> commit (HEAD)` ```bash # CHANGED vs STAGED -
akottr revised this gist
Sep 11, 2013 . 1 changed file with 12 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -108,6 +108,18 @@ git push bitbucket master Diff and Merging ---------------- #### understanding diff Flo: `changed -> staged -> commit (HEAD)` ```bash # CHANGED vs STAGED git diff # STAGED vs HEAD git diff --cached # CHANGED vs HEAD git diff HEAD ``` #### show diff ```bash # show diff not staged -
akottr revised this gist
Sep 5, 2013 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -8,6 +8,7 @@ Config ```bash git config --global user.name "username" git config --global user.email "[email protected]" git config --global color.diff true ``` #### Config for a dedicated repo -
akottr revised this gist
Aug 21, 2013 . 1 changed file with 11 additions and 7 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -176,6 +176,16 @@ git push <remote> <local branch name>:<remote branch to push into> git push origin develop-branch:master ``` #### delete branch ```bash # delete git branch -d develop-branch # force delete git branch -D develop-branch # delete remote branch git push origin --delete develop-branch ``` #### Show tags ```bash git tag @@ -200,10 +210,4 @@ git reset --soft HEAD^ git reset --soft HEAD~1 # undo last two commits git reset --soft HEAD~2 ``` -
akottr revised this gist
Aug 21, 2013 . 1 changed file with 14 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -169,6 +169,13 @@ git checkout origin/v0.9 git checkout -b experimental origin/v0.9 ``` #### push from branch to origin/master ```bash git push <remote> <local branch name>:<remote branch to push into> # example git push origin develop-branch:master ``` #### Show tags ```bash git tag @@ -193,4 +200,10 @@ git reset --soft HEAD^ git reset --soft HEAD~1 # undo last two commits git reset --soft HEAD~2 ``` ```bash git push <remote> <local branch name>:<remote branch to push into> # example git push origin develop-branch:master ```bash -
akottr revised this gist
Aug 16, 2013 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -86,8 +86,8 @@ git log -10 --color --stat ``` Repositories ------------ ### Create a new repoistory ```bash @@ -98,7 +98,7 @@ git remote add origin ssh://[email protected]/akottr/some-repo.git git push -u origin --all ``` ### push to different repository ```bash git remote add bitbucket http://[email protected]/akottr/some-repo.git git push bitbucket master -
akottr revised this gist
Aug 16, 2013 . 1 changed file with 7 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -89,6 +89,7 @@ git log -10 --color --stat Create repository ----------------- ### Create a new repoistory ```bash git init git add . @@ -97,6 +98,12 @@ git remote add origin ssh://[email protected]/akottr/some-repo.git git push -u origin --all ``` ### push to different repoistory ```bash git remote add bitbucket http://[email protected]/akottr/some-repo.git git push bitbucket master ``` Diff and Merging ---------------- -
akottr revised this gist
Aug 15, 2013 . 1 changed file with 5 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -180,5 +180,10 @@ Troubleshooting --------------- #### undo last commit ```bash # undo last commit git reset --soft HEAD^ # undo last (one) commit git reset --soft HEAD~1 # undo last two commits git reset --soft HEAD~2 ``` -
akottr revised this gist
Aug 15, 2013 . 1 changed file with 7 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -42,10 +42,6 @@ git remote -v git remote rename origin destination ``` Basic commands -------------- @@ -179,3 +175,10 @@ git checkout v0.9 git tag v0.9 git push origin --tags ``` Troubleshooting --------------- #### undo last commit ```bash git reset --soft HEAD^ ``` -
akottr revised this gist
Aug 15, 2013 . 1 changed file with 6 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -42,7 +42,10 @@ git remote -v git remote rename origin destination ``` #### undo last commit ```bash git reset --soft HEAD^ ``` Basic commands -------------- @@ -82,6 +85,8 @@ git checkout -- /my/directory/or/file git log -10 /my/directory/or/file # log history including rename follow git log -10 --follow /my/directory/or/file # show history with filenames git log -10 --color --stat ``` -
akottr revised this gist
Aug 14, 2013 . 1 changed file with 14 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -28,9 +28,21 @@ ssh -T [email protected] #### switch remote url ```bash git remote set-url origin http://[email protected]/akottr/some-repo.git ``` #### rename remote ```bash # 1. show remotes git remote -v # origin https://[email protected]/akottr/some-repo.git (fetch) # origin https://[email protected]/akottr/some-repo.git (push) # 2. rename git remote rename origin destination ``` Basic commands -------------- @@ -80,7 +92,7 @@ Create repository git init git add . git commit -m "init" git remote add origin ssh://[email protected]/akottr/some-repo.git git push -u origin --all ``` -
akottr revised this gist
Aug 14, 2013 . 1 changed file with 5 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -87,9 +87,12 @@ git push -u origin --all Diff and Merging ---------------- #### show diff ```bash # show diff not staged git diff --color # show diff of staging area git diff --color --cached /my/directory/or/file ``` #### show diff to remote branch -
akottr revised this gist
Aug 14, 2013 . 1 changed file with 14 additions and 5 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -139,14 +139,23 @@ git branch # Show all branch(es) git branch -a ``` #### checkout branch ```bash git checkout origin/v0.9 # create branch and checkout branch git checkout -b experimental origin/v0.9 ``` #### Show tags ```bash git tag ``` #### checkout tag ```bash git checkout v0.9 ``` #### create tag and push to upstream ```bash git tag v0.9 git push origin --tags ``` -
akottr revised this gist
Aug 14, 2013 . 1 changed file with 11 additions and 11 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -12,8 +12,8 @@ git config --global user.email "[email protected]" #### Config for a dedicated repo ```bash git config user.name "username" git config user.email "[email protected]" ``` #### If cygwin ssl error occurs @@ -52,6 +52,7 @@ git status git commit -m "some commit comment here" # commit and add in one step git commit -am "some commit comment here" ``` #### Push (pushes to the repository on github) ```bash @@ -66,7 +67,7 @@ git checkout -- /my/directory/or/file #### log history ```bash # log history git log -10 /my/directory/or/file # log history including rename follow git log -10 --follow /my/directory/or/file ``` @@ -129,21 +130,20 @@ git commit -am "manual merge" git push origin master ``` Branches and Tags ----------------- #### show branches ```bash # Show local branch(es) git branch # Show all branch(es) git branch -a ``` #### Show tags ```bash git tag ``` #### checkout branch ```bash git checkout origin/v0.9 -
akottr revised this gist
Aug 14, 2013 . 1 changed file with 85 additions and 82 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,149 +1,152 @@ Git / Github basic commands =========================== Config ------- #### Global config ```bash git config --global user.name "username" git config --global user.email "[email protected]" ``` #### Config for a dedicated repo ```bash git config --global user.name "username" git config --global user.email "[email protected]" ``` #### If cygwin ssl error occurs ```bash git config --global http.sslVerify false ``` #### Check SSH access ```bash ssh -T [email protected] ``` #### switch remote url ```bash git remote set-url origin http://[email protected]/akottr/sometest.git ``` Basic commands -------------- #### Clone ```bash git clone http://github.com/akottr/edu.git ``` #### Add to staging area ```bash git add . # show status after add git status ``` #### Commit (commits to the local repository) ```bash # commit git commit -m "some commit comment here" # commit and add in one step git commit -am "some commit comment here" #### Push (pushes to the repository on github) ```bash git push origin master ``` #### Revert (be aware of the blank after --) ```bash git checkout -- /my/directory/or/file ``` #### log history ```bash # log history git log -10 --follow /my/directory/or/file # log history including rename follow git log -10 --follow /my/directory/or/file ``` Create repository ----------------- ```bash git init git add . git commit -m "init" git remote add origin ssh://[email protected]/akottr/sometest.git git push -u origin --all ``` Diff and Merging ---------------- #### show diff of staging area ```bash git diff --cached --color /my/directory/or/file ``` #### show diff to remote branch ```bash # The git fetch command updates the local remote references. git fetch git diff --stat --color master origin/master ``` #### fetch and merge ```bash # 1. Fetch from repo git fetch # 2. See what has changed git diff --stat --color master origin/master git diff --name-status master origin/master # 3. See if fast-forward is possible (no merge confilcts) git status master origin/master # 4. merge git merge origin/master # or you can do once 'git config merge.defaultToUpstream true'. then 'git merge' can be called without parameters # 5. show conflicts (if any) git diff --name-only --diff-filter=U # 6. resolve confilcts and then git commit -am "manual merge" # 7. push your changes to upstream git push origin master ``` #### pull and merge ```bash # 1. Pull from repo git pull # 2. show conflicts (if any) git diff --name-only --diff-filter=U # 3. resolve confilcts and then git commit -am "manual merge" # 4. push your changes to upstream git push origin master ``` Branches -------- ### show branches First clone repository ```bash git clone http://github.com/akottr/edu.git ``` #### show branches ```bash # Show local branch(es) git branch # Show all branch(es) git branch -a ``` #### checkout branch ```bash git checkout origin/v0.9 # create branch and checkout branch git checkout -b experimental origin/v0.9 ```
NewerOlder