Skip to content

Instantly share code, notes, and snippets.

@akottr
Last active April 29, 2019 20:49

Revisions

  1. akottr revised this gist Feb 6, 2015. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions git-commands.md
    Original 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
  2. akottr revised this gist Feb 6, 2015. 1 changed file with 5 additions and 3 deletions.
    8 changes: 5 additions & 3 deletions git-commands.md
    Original 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
    ```
  3. akottr revised this gist Dec 10, 2014. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions git-commands.md
    Original 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
  4. akottr revised this gist Feb 13, 2014. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions git-commands.md
    Original 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] $`
    #### 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] /'
    }
  5. akottr revised this gist Feb 13, 2014. 1 changed file with 9 additions and 0 deletions.
    9 changes: 9 additions & 0 deletions git-commands.md
    Original 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
  6. akottr revised this gist Feb 13, 2014. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions git-commands.md
    Original file line number Diff line number Diff line change
    @@ -174,7 +174,7 @@ git fetch
    git diff --stat --color master origin/master
    ```

    #### fetch + merge
    #### 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
    #### pull + merge + push
    ```bash
    # 1. Pull from repo
    git pull
  7. akottr revised this gist Feb 13, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git-commands.md
    Original 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
    #### pull + rebase + push
    ```bash
    git fetch
    git rebase
  8. akottr revised this gist Feb 13, 2014. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions git-commands.md
    Original file line number Diff line number Diff line change
    @@ -207,7 +207,6 @@ git push origin master

    ### pull + rebase + push
    ```bash
    git push
    git fetch
    git rebase
    # -> MANUAL MERGE <-
    @@ -217,7 +216,7 @@ git push
    ```

    ```bash
    # long version (copied from itellij console)
    # long version (copied from intellij console)
    git push --progress origin master:master
    git fetch --progress --prune origin
    git rebase origin/master
  9. akottr revised this gist Feb 13, 2014. 1 changed file with 33 additions and 34 deletions.
    67 changes: 33 additions & 34 deletions git-commands.md
    Original file line number Diff line number Diff line change
    @@ -43,40 +43,6 @@ git remote -v
    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
    --------------

    @@ -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
    ------------
  10. akottr revised this gist Feb 13, 2014. 1 changed file with 69 additions and 5 deletions.
    74 changes: 69 additions & 5 deletions git-commands.md
    Original 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)
    # 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 and merge
    #### 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 and merge
    #### 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
    ```
    ```


  11. akottr revised this gist Jan 23, 2014. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions git-commands.md
    Original 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
    ```
  12. akottr revised this gist Jan 23, 2014. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions git-commands.md
    Original 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
  13. akottr revised this gist Nov 13, 2013. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion git-commands.md
    Original file line number Diff line number Diff line change
    @@ -177,9 +177,11 @@ git branch -a
    ```
    #### checkout branch
    ```bash
    git checkout origin/v0.9
    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
  14. akottr revised this gist Nov 12, 2013. 1 changed file with 11 additions and 0 deletions.
    11 changes: 11 additions & 0 deletions git-commands.md
    Original 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
  15. akottr revised this gist Nov 12, 2013. 1 changed file with 7 additions and 0 deletions.
    7 changes: 7 additions & 0 deletions git-commands.md
    Original 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>
  16. akottr revised this gist Sep 11, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git-commands.md
    Original file line number Diff line number Diff line change
    @@ -109,7 +109,7 @@ Diff and Merging
    ----------------

    #### understanding diff
    Flo: `changed -> staged -> commit (HEAD)`
    Flow: `changed -> staged -> commit (HEAD)`

    ```bash
    # CHANGED vs STAGED
  17. akottr revised this gist Sep 11, 2013. 1 changed file with 12 additions and 0 deletions.
    12 changes: 12 additions & 0 deletions git-commands.md
    Original 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
  18. akottr revised this gist Sep 5, 2013. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions git-commands.md
    Original 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
  19. akottr revised this gist Aug 21, 2013. 1 changed file with 11 additions and 7 deletions.
    18 changes: 11 additions & 7 deletions git-commands.md
    Original 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
    ```

    ```bash
    git push <remote> <local branch name>:<remote branch to push into>
    # example
    git push origin develop-branch:master
    ```bash
    ```
  20. akottr revised this gist Aug 21, 2013. 1 changed file with 14 additions and 1 deletion.
    15 changes: 14 additions & 1 deletion git-commands.md
    Original 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
  21. akottr revised this gist Aug 16, 2013. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions git-commands.md
    Original file line number Diff line number Diff line change
    @@ -86,8 +86,8 @@ git log -10 --color --stat
    ```


    Create repository
    -----------------
    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 repoistory
    ### push to different repository
    ```bash
    git remote add bitbucket http://[email protected]/akottr/some-repo.git
    git push bitbucket master
  22. akottr revised this gist Aug 16, 2013. 1 changed file with 7 additions and 0 deletions.
    7 changes: 7 additions & 0 deletions git-commands.md
    Original 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
    ----------------

  23. akottr revised this gist Aug 15, 2013. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions git-commands.md
    Original 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
    ```
  24. akottr revised this gist Aug 15, 2013. 1 changed file with 7 additions and 4 deletions.
    11 changes: 7 additions & 4 deletions git-commands.md
    Original file line number Diff line number Diff line change
    @@ -42,10 +42,6 @@ git remote -v
    git remote rename origin destination
    ```

    #### undo last commit
    ```bash
    git reset --soft HEAD^
    ```
    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^
    ```
  25. akottr revised this gist Aug 15, 2013. 1 changed file with 6 additions and 1 deletion.
    7 changes: 6 additions & 1 deletion git-commands.md
    Original 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
    ```


  26. akottr revised this gist Aug 14, 2013. 1 changed file with 14 additions and 2 deletions.
    16 changes: 14 additions & 2 deletions git-commands.md
    Original 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/sometest.git
    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/sometest.git
    git remote add origin ssh://[email protected]/akottr/some-repo.git
    git push -u origin --all
    ```

  27. akottr revised this gist Aug 14, 2013. 1 changed file with 5 additions and 2 deletions.
    7 changes: 5 additions & 2 deletions git-commands.md
    Original file line number Diff line number Diff line change
    @@ -87,9 +87,12 @@ git push -u origin --all
    Diff and Merging
    ----------------

    #### show diff of staging area
    #### show diff
    ```bash
    git diff --cached --color /my/directory/or/file
    # 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
  28. akottr revised this gist Aug 14, 2013. 1 changed file with 14 additions and 5 deletions.
    19 changes: 14 additions & 5 deletions git-commands.md
    Original file line number Diff line number Diff line change
    @@ -139,14 +139,23 @@ git branch
    # Show all branch(es)
    git branch -a
    ```
    #### Show tags
    ```bash
    git tag
    ```

    #### 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
    ```
  29. akottr revised this gist Aug 14, 2013. 1 changed file with 11 additions and 11 deletions.
    22 changes: 11 additions & 11 deletions git-commands.md
    Original 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 --global user.name "username"
    git config --global user.email "[email protected]"
    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 --follow /my/directory/or/file
    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
    --------

    ### show branches
    First clone repository
    ```bash
    git clone http://github.com/akottr/edu.git
    ```
    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
  30. akottr revised this gist Aug 14, 2013. 1 changed file with 85 additions and 82 deletions.
    167 changes: 85 additions & 82 deletions git-commands.md
    Original file line number Diff line number Diff line change
    @@ -1,149 +1,152 @@
    Git / Github basic commands
    ===========================

    ### Cygwin ssl error:
    Config
    -------

    #### Global config
    ```bash
    git config --global http.sslVerify false
    git config --global user.name "username"
    git config --global user.email "[email protected]"
    ```
    ### Config:

    #### 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 user.email "[email protected]"
    git config --global http.sslVerify false
    ```

    ### Check SSH access
    #### Check SSH access
    ```bash
    ssh -T [email protected]
    ```

    ### Clone
    #### 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
    #### Add to staging area
    ```bash
    git add .
    # show status after add
    git status
    ```

    ### Commit (commits to the local repository)
    #### Commit (commits to the local repository)
    ```bash
    # commit
    git commit -m "some commit comment here"
    ```
    ### Commit AND Add
    ```bash
    # commit and add in one step
    git commit -am "some commit comment here"
    ```

    ### Push (pushes to the repository on github)
    #### Push (pushes to the repository on github)
    ```bash
    git push origin master
    ```

    ### Revert (be aware of the blank after --)
    #### Revert (be aware of the blank after --)
    ```bash
    git checkout -- /my/directory/or/file
    ```

    ### log history including rename follow
    #### 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
    ```

    ### show diff of staging area

    Create repository
    -----------------

    ```bash
    git diff --cached --color /my/directory/or/file
    git init
    git add .
    git commit -m "init"
    git remote add origin ssh://[email protected]/akottr/sometest.git
    git push -u origin --all
    ```

    ### show diff to remote branch
    The git fetch command updates the local remote references.
    Diff and Merging
    ----------------

    #### show diff of staging area
    ```bash
    git fetch
    git diff --cached --color /my/directory/or/file
    ```
    See what has changed

    #### show diff to remote branch
    ```bash
    # The git fetch command updates the local remote references.
    git fetch
    git diff --stat --color master origin/master
    ```
    or

    #### 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
    ```
    ### Manual merge after update
    #### pull and merge
    ```bash
    # 1. Pull from repo
    git pull
    ```
    See which files are in conflict
    ```bash
    # 2. show conflicts (if any)
    git diff --name-only --diff-filter=U
    ```
    Now merge manually if necessary
    ```bash
    # 3. resolve confilcts and then
    git commit -am "manual merge"
    ```
    ```bash
    # 4. push your changes to upstream
    git push origin master
    ```

    ### Manual merge after update using fetch and merge
    The git fetch command updates the local remote references.
    ```bash
    git fetch
    ```
    See if fast-forward is possible (no merge confilcts)
    ```bash
    git status master remotes/origin/master
    ```
    Merge the stuff from the remote branch into the current local branch
    ```bash
    git merge origin/master
    ```
    or you do once
    ```bash
    git config merge.defaultToUpstream true
    ```
    then git merge can be called without parameters
    ```bash
    git merge
    ```
    ### Checkout a branch
    Branches
    --------

    ### show branches
    First clone repository
    ```bash
    git clone http://github.com/akottr/edu.git
    ```
    Show local branch(es):
    #### show branches
    ```bash
    # Show local branch(es)
    git branch
    ```
    Show all branch(es):
    ```bash
    # Show all branch(es)
    git branch -a
    ```
    Checkout the desired branch
    ```bash
    git checkout -b experimental remotes/origin/v0.9
    ```
    ### switch between branches (that are already checked out)
    switch back to master branch
    ```bash
    git checkout master
    ```
    switch back to v0.9
    ```bash
    git checkout v0.9
    ```

    ### switch remote url
    #### checkout branch
    ```bash
    git remote set-url origin http://[email protected]/akottr/sometest.git
    git checkout origin/v0.9
    # create branch and checkout branch
    git checkout -b experimental origin/v0.9
    ```

    ### create new 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
    ```