Skip to content

Instantly share code, notes, and snippets.

@ufukomer
Last active July 7, 2020 11:08
Show Gist options
  • Select an option

  • Save ufukomer/c52de8b72811cc7d5eed to your computer and use it in GitHub Desktop.

Select an option

Save ufukomer/c52de8b72811cc7d5eed to your computer and use it in GitHub Desktop.

Revisions

  1. ufukomer revised this gist Jul 7, 2020. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions git-commands.md
    Original file line number Diff line number Diff line change
    @@ -123,4 +123,10 @@ git rev-parse --short HEAD

    ```
    git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d
    ```

    ### Ignore changes

    ```
    git update-index --assume-unchanged
    ```
  2. ufukomer revised this gist Jul 9, 2018. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions git-commands.md
    Original file line number Diff line number Diff line change
    @@ -117,4 +117,10 @@ https://stackoverflow.com/a/19859644/3650955

    ```
    git rev-parse --short HEAD
    ```

    ### Delete merged branches

    ```
    git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d
    ```
  3. ufukomer revised this gist Mar 16, 2018. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions git-commands.md
    Original file line number Diff line number Diff line change
    @@ -112,3 +112,9 @@ git branch -m <old_name> <new_name>
    ### Recommit unpushed commit

    https://stackoverflow.com/a/19859644/3650955

    ### Print short hash of last commit

    ```
    git rev-parse --short HEAD
    ```
  4. ufukomer revised this gist Jul 5, 2017. 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
    @@ -108,3 +108,7 @@ git push --force
    ```
    git branch -m <old_name> <new_name>
    ```

    ### Recommit unpushed commit

    https://stackoverflow.com/a/19859644/3650955
  5. ufukomer revised this gist Jun 15, 2017. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions git-commands.md
    Original file line number Diff line number Diff line change
    @@ -102,3 +102,9 @@ git checkout -- a // a is directory
    git commit --allow-empty -m "Trigger"
    git push --force
    ```

    ### Rename local branch

    ```
    git branch -m <old_name> <new_name>
    ```
  6. ufukomer revised this gist Jun 6, 2017. 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
    @@ -95,3 +95,10 @@ git checkout <commit_sha>
    ```
    git checkout -- a // a is directory
    ```

    ### Empty commit

    ```
    git commit --allow-empty -m "Trigger"
    git push --force
    ```
  7. ufukomer revised this gist Feb 16, 2017. 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
    @@ -93,6 +93,5 @@ git checkout <commit_sha>
    ### Directory hard reset (have not tried yet)

    ```
    git checkout -- a
    git checkout -- a // a is directory
    ```
    a is diretory.
  8. ufukomer revised this gist Feb 16, 2017. 1 changed file with 8 additions and 1 deletion.
    9 changes: 8 additions & 1 deletion git-commands.md
    Original file line number Diff line number Diff line change
    @@ -88,4 +88,11 @@ git reset --hard origin/master
    ```
    git clone -n <repo_name>
    git checkout <commit_sha>
    ```
    ```

    ### Directory hard reset (have not tried yet)

    ```
    git checkout -- a
    ```
    a is diretory.
  9. ufukomer revised this gist Nov 4, 2016. 1 changed file with 23 additions and 13 deletions.
    36 changes: 23 additions & 13 deletions git-commands.md
    Original file line number Diff line number Diff line change
    @@ -4,9 +4,11 @@

    ### Push

    `$ git add .`
    `$ git commit -m "Your message"`
    `$ git push -u origin master`
    ```
    $ git add .
    $ git commit -m "Your message"
    $ git push -u origin master
    ```

    ### Force push

    @@ -18,13 +20,19 @@

    ### Remove commit

    `$ git reset --hard HEAD~1`
    `$ git push origin HEAD --force`
    ```
    $ git reset --hard HEAD~1
    $ git push origin HEAD --force
    ```

    ### Remove file from repositery (not from local)
    `$ git rm -r --cached some-directory`
    `$git commit -m 'Remove the now ignored directory "some-directory"'`
    `$ git push origin master`


    ```
    $ git rm -r --cached some-directory
    $git commit -m 'Remove the now ignored directory "some-directory"'
    $ git push origin master
    ```

    ### md syntax

    @@ -34,11 +42,13 @@ https://github.com/tchapi/markdown-cheatsheet/blob/master/README.md

    ### remove accidently pushed (.idea) folder

    `$ echo '.idea' >> .gitignore`
    `$ git rm -r --cached .idea`
    `$ git add .gitignore`
    `$ git commit -m '(some message stating you added .idea to ignored entries)'`
    `$ git push`
    ```
    $ echo '.idea' >> .gitignore
    $ git rm -r --cached .idea
    $ git add .gitignore
    $ git commit -m '(some message stating you added .idea to ignored entries)'
    $ git push
    ```

    ### edit old pushed commit message

  10. ufukomer revised this gist Nov 4, 2016. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions git-commands.md
    Original file line number Diff line number Diff line change
    @@ -54,13 +54,13 @@ then run: `$ git push --force`

    ### Git rebase

    1 - `$ git rebase develop`
    - `$ git rebase develop`

    1 - `$ git add -u`
    - `$ git add -u`

    1 - `$ git rebase --continue`
    - `$ git rebase --continue`

    1 - `$ git push --force origin sample(your branch name)`
    - `$ git push --force origin sample(your branch name)`

    [Stackoverflow](http://stackoverflow.com/questions/11563319/git-rebase-basics)

  11. ufukomer revised this gist Nov 4, 2016. No changes.
  12. ufukomer revised this gist Nov 4, 2016. 1 changed file with 21 additions and 24 deletions.
    45 changes: 21 additions & 24 deletions git-commands.md
    Original file line number Diff line number Diff line change
    @@ -1,33 +1,30 @@
    ### Clone respotory to your pc

    git clone 'ssh clone url'
    `$ git clone 'ssh clone url'`

    ### Push

    git add .

    git commit -m "Your message"

    git push -u origin master
    `$ git add .`
    `$ git commit -m "Your message"`
    `$ git push -u origin master`

    ### Force push

    git push origin master --force
    `$ git push origin master --force`

    ### Pull

    git pull
    `$ git pull`

    ### Remove commit

    git reset --hard HEAD~1

    git push origin HEAD --force
    `$ git reset --hard HEAD~1`
    `$ git push origin HEAD --force`

    ### Remove file from repositery (not from local)
    git rm -r --cached some-directory
    git commit -m 'Remove the now ignored directory "some-directory"'
    git push origin master
    `$ git rm -r --cached some-directory`
    `$git commit -m 'Remove the now ignored directory "some-directory"'`
    `$ git push origin master`

    ### md syntax

    @@ -37,16 +34,16 @@ https://github.com/tchapi/markdown-cheatsheet/blob/master/README.md

    ### remove accidently pushed (.idea) folder

    $ echo '.idea' >> .gitignore
    $ git rm -r --cached .idea
    $ git add .gitignore
    $ git commit -m '(some message stating you added .idea to ignored entries)'
    $ git push
    `$ echo '.idea' >> .gitignore`
    `$ git rm -r --cached .idea`
    `$ git add .gitignore`
    `$ git commit -m '(some message stating you added .idea to ignored entries)'`
    `$ git push`

    ### edit old pushed commit message

    http://schacon.github.io/history.html
    then run: git push --force
    then run: `$ git push --force`

    ### update forked repository

    @@ -57,13 +54,13 @@ then run: git push --force

    ### Git rebase

    - `$ git rebase develop`
    1 - `$ git rebase develop`

    - `$ git add -u`
    1 - `$ git add -u`

    - `$ git rebase --continue`
    1 - `$ git rebase --continue`

    - `$ git push --force origin sample(your branch name)`
    1 - `$ git push --force origin sample(your branch name)`

    [Stackoverflow](http://stackoverflow.com/questions/11563319/git-rebase-basics)

  13. ufukomer revised this gist Nov 4, 2016. No changes.
  14. ufukomer revised this gist Nov 4, 2016. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions git-commands.md
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,9 @@ git clone 'ssh clone url'
    ### Push

    git add .

    git commit -m "Your message"

    git push -u origin master

    ### Force push
    @@ -19,6 +21,7 @@ git pull
    ### Remove commit

    git reset --hard HEAD~1

    git push origin HEAD --force

    ### Remove file from repositery (not from local)
  15. ufukomer revised this gist Sep 22, 2016. 1 changed file with 8 additions and 1 deletion.
    9 changes: 8 additions & 1 deletion git-commands.md
    Original file line number Diff line number Diff line change
    @@ -71,4 +71,11 @@ git fetch --all
    git reset --hard origin/master
    ```

    [Stackoverflow](http://stackoverflow.com/a/8888015/3650955)
    [Stackoverflow](http://stackoverflow.com/a/8888015/3650955)

    ### Clone with specific commit

    ```
    git clone -n <repo_name>
    git checkout <commit_sha>
    ```
  16. ufukomer revised this gist Jun 24, 2016. 1 changed file with 10 additions and 1 deletion.
    11 changes: 10 additions & 1 deletion git-commands.md
    Original file line number Diff line number Diff line change
    @@ -62,4 +62,13 @@ then run: git push --force

    - `$ git push --force origin sample(your branch name)`

    [Stackoverflow](http://stackoverflow.com/questions/11563319/git-rebase-basics)
    [Stackoverflow](http://stackoverflow.com/questions/11563319/git-rebase-basics)

    ### Git Reset Origin

    ```
    git fetch --all
    git reset --hard origin/master
    ```

    [Stackoverflow](http://stackoverflow.com/a/8888015/3650955)
  17. ufukomer revised this gist Jun 15, 2016. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions git-commands.md
    Original file line number Diff line number Diff line change
    @@ -54,12 +54,12 @@ then run: git push --force

    ### Git rebase

    1 - `$ git rebase develop`
    - `$ git rebase develop`

    1 - `$ git add -u`
    - `$ git add -u`

    1 - `$ git rebase --continue`
    - `$ git rebase --continue`

    1 - `$ git push --force origin sample(your branch name)`
    - `$ git push --force origin sample(your branch name)`

    [Stackoverflow](http://stackoverflow.com/questions/11563319/git-rebase-basics)
  18. ufukomer revised this gist Jun 15, 2016. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions git-commands.md
    Original file line number Diff line number Diff line change
    @@ -54,12 +54,12 @@ then run: git push --force

    ### Git rebase

    1- `$ git rebase develop`
    1 - `$ git rebase develop`

    1- `$ git add -u`
    1 - `$ git add -u`

    1- `$ git rebase --continue`
    1 - `$ git rebase --continue`

    1- `$ git push --force origin sample(your branch name)`
    1 - `$ git push --force origin sample(your branch name)`

    [Stackoverflow](http://stackoverflow.com/questions/11563319/git-rebase-basics)
  19. ufukomer revised this gist Jun 15, 2016. 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,9 +53,13 @@ then run: git push --force


    ### Git rebase

    1- `$ git rebase develop`

    1- `$ git add -u`

    1- `$ git rebase --continue`

    1- `$ git push --force origin sample(your branch name)`

    [Stackoverflow](http://stackoverflow.com/questions/11563319/git-rebase-basics)
  20. ufukomer revised this gist Jun 15, 2016. 1 changed file with 5 additions and 4 deletions.
    9 changes: 5 additions & 4 deletions git-commands.md
    Original file line number Diff line number Diff line change
    @@ -53,8 +53,9 @@ then run: git push --force


    ### Git rebase
    `$ git rebase develop`
    `$ git add -u`
    `$ git rebase --continue`
    `$ git push --force origin sample(your branch name)`
    1- `$ git rebase develop`
    1- `$ git add -u`
    1- `$ git rebase --continue`
    1- `$ git push --force origin sample(your branch name)`

    [Stackoverflow](http://stackoverflow.com/questions/11563319/git-rebase-basics)
  21. ufukomer revised this gist Jun 15, 2016. 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,4 +53,8 @@ then run: git push --force


    ### Git rebase
    `$ git rebase develop`
    `$ git add -u`
    `$ git rebase --continue`
    `$ git push --force origin sample(your branch name)`
    [Stackoverflow](http://stackoverflow.com/questions/11563319/git-rebase-basics)
  22. ufukomer revised this gist Jun 9, 2016. 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
    @@ -48,4 +48,9 @@ then run: git push --force
    ### update forked repository

    - [How do I update a GitHub forked repository?](http://stackoverflow.com/a/7244456/3650955)
    - [Pull new updates from original GitHub repository into forked GitHub repository](http://stackoverflow.com/a/3903835/3650955)
    - [Pull new updates from original GitHub repository into forked GitHub repository](http://stackoverflow.com/a/3903835/3650955)



    ### Git rebase
    [Stackoverflow](http://stackoverflow.com/questions/11563319/git-rebase-basics)
  23. ufukomer revised this gist Jun 2, 2016. 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
    @@ -47,5 +47,5 @@ then run: git push --force

    ### update forked repository

    [How do I update a GitHub forked repository?](http://stackoverflow.com/a/7244456/3650955)
    [Pull new updates from original GitHub repository into forked GitHub repository](http://stackoverflow.com/a/3903835/3650955)
    - [How do I update a GitHub forked repository?](http://stackoverflow.com/a/7244456/3650955)
    - [Pull new updates from original GitHub repository into forked GitHub repository](http://stackoverflow.com/a/3903835/3650955)
  24. ufukomer revised this gist Jun 2, 2016. 1 changed file with 19 additions and 10 deletions.
    29 changes: 19 additions & 10 deletions git-commands.md
    Original file line number Diff line number Diff line change
    @@ -1,42 +1,51 @@
    // Clone respotory to your pc
    ### Clone respotory to your pc

    git clone 'ssh clone url'

    // Push
    ### Push

    git add .
    git commit -m "Your message"
    git push -u origin master

    // Force push
    ### Force push

    git push origin master --force

    // Pull
    ### Pull

    git pull

    // Remove commit
    ### Remove commit

    git reset --hard HEAD~1
    git push origin HEAD --force

    // Remove file from repositery (not from local)
    ### Remove file from repositery (not from local)
    git rm -r --cached some-directory
    git commit -m 'Remove the now ignored directory "some-directory"'
    git push origin master

    // md syntax
    ### md syntax

    https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet
    https://confluence.atlassian.com/display/STASH/Markdown+syntax+guide
    https://github.com/tchapi/markdown-cheatsheet/blob/master/README.md

    // remove accidently pushed (.idea) folder
    ### remove accidently pushed (.idea) folder

    $ echo '.idea' >> .gitignore
    $ git rm -r --cached .idea
    $ git add .gitignore
    $ git commit -m '(some message stating you added .idea to ignored entries)'
    $ git push

    // edit old pushed commit message
    ### edit old pushed commit message

    http://schacon.github.io/history.html
    then run: git push --force

    // update forked repository
    ### update forked repository

    [How do I update a GitHub forked repository?](http://stackoverflow.com/a/7244456/3650955)
    [Pull new updates from original GitHub repository into forked GitHub repository](http://stackoverflow.com/a/3903835/3650955)
  25. ufukomer renamed this gist Jun 2, 2016. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  26. ufukomer revised this gist Jun 2, 2016. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion Git Commands
    Original file line number Diff line number Diff line change
    @@ -35,4 +35,8 @@ $ git push

    // edit old pushed commit message
    http://schacon.github.io/history.html
    then run: git push --force
    then run: git push --force

    // update forked repository
    [How do I update a GitHub forked repository?](http://stackoverflow.com/a/7244456/3650955)
    [Pull new updates from original GitHub repository into forked GitHub repository](http://stackoverflow.com/a/3903835/3650955)
  27. ufukomer revised this gist May 16, 2016. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion Git Commands
    Original file line number Diff line number Diff line change
    @@ -31,4 +31,8 @@ $ echo '.idea' >> .gitignore
    $ git rm -r --cached .idea
    $ git add .gitignore
    $ git commit -m '(some message stating you added .idea to ignored entries)'
    $ git push
    $ git push

    // edit old pushed commit message
    http://schacon.github.io/history.html
    then run: git push --force
  28. ufukomer revised this gist May 9, 2016. 1 changed file with 8 additions and 1 deletion.
    9 changes: 8 additions & 1 deletion Git Commands
    Original file line number Diff line number Diff line change
    @@ -24,4 +24,11 @@ git push origin master
    // md syntax
    https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet
    https://confluence.atlassian.com/display/STASH/Markdown+syntax+guide
    https://github.com/tchapi/markdown-cheatsheet/blob/master/README.md
    https://github.com/tchapi/markdown-cheatsheet/blob/master/README.md

    // remove accidently pushed (.idea) folder
    $ echo '.idea' >> .gitignore
    $ git rm -r --cached .idea
    $ git add .gitignore
    $ git commit -m '(some message stating you added .idea to ignored entries)'
    $ git push
  29. ufukomer revised this gist Aug 23, 2015. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions Git Commands
    Original file line number Diff line number Diff line change
    @@ -16,6 +16,11 @@ git pull
    git reset --hard HEAD~1
    git push origin HEAD --force

    // Remove file from repositery (not from local)
    git rm -r --cached some-directory
    git commit -m 'Remove the now ignored directory "some-directory"'
    git push origin master

    // md syntax
    https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet
    https://confluence.atlassian.com/display/STASH/Markdown+syntax+guide
  30. ufukomer renamed this gist May 14, 2015. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.