Skip to content

Instantly share code, notes, and snippets.

@jorwan
Forked from frangeris/commands.md
Last active August 29, 2015 14:19
Show Gist options
  • Select an option

  • Save jorwan/602e07d2bcd7828f5659 to your computer and use it in GitHub Desktop.

Select an option

Save jorwan/602e07d2bcd7828f5659 to your computer and use it in GitHub Desktop.

Revisions

  1. @frangeris frangeris revised this gist Apr 15, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion commands.md
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    Common git commands
    ===================

    Hey! I'm your first Markdown document in **StackEdit**[^stackedit]. Don't delete me, I'm very helpful! I can be recovered anyway in the **Utils** tab of the <i class="icon-cog"></i> **Settings** dialog.
    This is a list of useful commands for git for fast search and ops developers, enjoy and comments for suggest all welcomes :D

    -------------
    Public repo .tar for download versions:
  2. @frangeris frangeris revised this gist Apr 15, 2015. 2 changed files with 124 additions and 44 deletions.
    124 changes: 124 additions & 0 deletions commands.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,124 @@
    Common git commands
    ===================

    Hey! I'm your first Markdown document in **StackEdit**[^stackedit]. Don't delete me, I'm very helpful! I can be recovered anyway in the **Utils** tab of the <i class="icon-cog"></i> **Settings** dialog.

    -------------
    Public repo .tar for download versions:
    [https://www.kernel.org/pub/software/scm/git/](https://www.kernel.org/pub/software/scm/git/)


    **Delete with git all files listed as deleted:**
    ```sh
    $ git rm $(git ls-files --deleted)
    ```

    **Delete a branch DOWN in the local repository:**
    ```sh
    $ git branch [branch name] --delete
    ```

    **Delete a branch UP in the services repository:**
    ```sh
    $ git push origin --delete [branch name]
    ```

    **Do not track changes on specific file:**
    ```sh
    $ git update-index --assume-unchanged [file]
    ```

    **Track changes again:**
    ```sh
    $ git update-index --no-assume-unchanged
    ```

    **List hidden tracked files:**
    ```sh
    $ git ls-files -v | grep '^[[:lower:]]'
    ```

    **Cleaning up cache when git ignore fail (options):**
    ```sh
    $ git rm -r --cached .
    $ git add .
    $ git commit -m "Fixed untracked files"
    ```

    **Clone a repo specifying the branch:**
    ```sh
    $ git clone -b <branch> <myproject>.git
    ```

    **Ignore mode file change, setting up git:**
    ```sh
    $ git config core.fileMode false
    ```

    **git checkout, doesn't work... possibilities:**
    ```sh
    $ git config --global core.autocrlf false
    $ vim .gitattributes # comment line "* text=auto"
    ```

    **Setting up git color:**
    ```sh
    $ git config --global color.ui true
    ```

    **Rolling back a commit:**
    ```sh
    $ git reset --soft 'HEAD^'
    ```

    **Discard last commit:**
    ```sh
    $ git reset HEAD --hard
    $ git reset --hard origin/master
    ```

    **Merging conflicts (accept theirs):**
    ```sh
    $ git checkout --theirs
    ```

    **Merging conflicts (accept ours):**
    ```sh
    $ git checkout --ours
    ```

    **Remove a remote:**
    ```sh
    $ git remote rm <remote>
    ```

    **Resolve problem with CRLF sequence:**
    ```sh
    $ git diff --ignore-space-at-eol
    ```

    **Add just tracked files to the stage:**
    ```sh
    $ git add -u .
    ```

    **Revert changes on a specifuc file commited and begin again:**
    ```sh
    $ git checkout commit-reff~1 -- <file name>
    ```

    **Remove the last commit and set the change to "Changed but not updated":**
    ```sh
    $ git reset HEAD~1
    ```

    **Export a "clean" project:**
    ```sh
    $ git archive master | tar -x -C </somewhere/else>
    $ git archive master | bzip2 > <source.tar.bz2>
    $ git archive --format zip --output <zipfile.zip> master
    ```
    > **Note:** This is a synonym to svn export. What this does is export and compress a repository without any .git* files.
    **Removing file from all history:**
    [https://help.github.com/articles/remove-sensitive-data/](https://help.github.com/articles/remove-sensitive-data/)
    44 changes: 0 additions & 44 deletions commands.txt
    Original file line number Diff line number Diff line change
    @@ -1,44 +0,0 @@
    GIT
    ===
    [PUBLIC REPO .tar] https://www.kernel.org/pub/software/scm/git/

    [DELETE ALL RM] git rm $(git ls-files --deleted)

    [DELETE BRANCH DOWN] git branch <branchName> --delete

    [DELETE BRANCH UP] git push origin --delete <branchName>

    [DONT TRACK CHANGES] git update-index --assume-unchanged <file>

    [TRACK CHANGES] git update-index --no-assume-unchanged <file>

    [LIST HIDDEN TRACKS] git ls-files -v | grep '^[[:lower:]]'

    [CLEANING UP CACHE WHEN GIT IGNORE FAIL]
    git rm -r --cached .
    git add .
    git commit -m "Fixed untracked files"

    [CLONE BRANCH] git clone -b <branch> git@<domain>:<user>/<myproject>.git

    [IGNORE MODE FILE] git config core.fileMode false

    [CHECKOUT DOESN'T WORK] git config --global core.autocrlf false
    vim .gitattributes # comment line "* text=auto"

    [GIT COLOR] git config --global color.ui true

    [ROLLING BACK A COMMIT] git reset --soft 'HEAD^'

    [DISCARD LAST COMMIT] git reset HEAD --hard
    git reset --hard origin/master

    [ACCEPT THEIRS MERGE] git checkout --theirs

    [ACCEPT OURS MERGE] git checkout --ours

    [REMOVE REMOTE] git remote rm <remote>

    [PROBLEM CRLF SEQUENCE] git diff --ignore-space-at-eol

    [REMOVE FILE FROM ALL HISTORY] https://help.github.com/articles/remove-sensitive-data/
  3. @frangeris frangeris renamed this gist Apr 15, 2015. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. @frangeris frangeris renamed this gist Apr 15, 2015. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  5. @frangeris frangeris revised this gist Feb 23, 2015. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions git_commands
    Original file line number Diff line number Diff line change
    @@ -24,6 +24,7 @@ GIT
    [IGNORE MODE FILE] git config core.fileMode false

    [CHECKOUT DOESN'T WORK] git config --global core.autocrlf false
    vim .gitattributes # comment line "* text=auto"

    [GIT COLOR] git config --global color.ui true

  6. @frangeris frangeris revised this gist Jan 16, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git_commands
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    GIT
    ===
    [PUBLIC REPO] https://www.kernel.org/pub/software/scm/git/
    [PUBLIC REPO .tar] https://www.kernel.org/pub/software/scm/git/

    [DELETE ALL RM] git rm $(git ls-files --deleted)

  7. @frangeris frangeris revised this gist Jan 16, 2015. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions git_commands
    Original file line number Diff line number Diff line change
    @@ -39,3 +39,5 @@ GIT
    [REMOVE REMOTE] git remote rm <remote>

    [PROBLEM CRLF SEQUENCE] git diff --ignore-space-at-eol

    [REMOVE FILE FROM ALL HISTORY] https://help.github.com/articles/remove-sensitive-data/
  8. @frangeris frangeris revised this gist Sep 10, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git_commands
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,7 @@ GIT

    [TRACK CHANGES] git update-index --no-assume-unchanged <file>

    [LIST TRACKS] git ls-files -v | grep '^[[:lower:]]'
    [LIST HIDDEN TRACKS] git ls-files -v | grep '^[[:lower:]]'

    [CLEANING UP CACHE WHEN GIT IGNORE FAIL]
    git rm -r --cached .
  9. @frangeris frangeris revised this gist Sep 10, 2014. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions git_commands
    Original file line number Diff line number Diff line change
    @@ -37,3 +37,5 @@ GIT
    [ACCEPT OURS MERGE] git checkout --ours

    [REMOVE REMOTE] git remote rm <remote>

    [PROBLEM CRLF SEQUENCE] git diff --ignore-space-at-eol
  10. @frangeris frangeris revised this gist Aug 20, 2014. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions git_commands
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,7 @@
    GIT
    ===
    [PUBLIC REPO] https://www.kernel.org/pub/software/scm/git/

    [DELETE ALL RM] git rm $(git ls-files --deleted)

    [DELETE BRANCH DOWN] git branch <branchName> --delete
  11. @frangeris frangeris revised this gist Aug 13, 2014. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions git_commands
    Original file line number Diff line number Diff line change
    @@ -10,6 +10,8 @@ GIT

    [TRACK CHANGES] git update-index --no-assume-unchanged <file>

    [LIST TRACKS] git ls-files -v | grep '^[[:lower:]]'

    [CLEANING UP CACHE WHEN GIT IGNORE FAIL]
    git rm -r --cached .
    git add .
  12. @frangeris frangeris revised this gist Aug 12, 2014. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions git_commands
    Original file line number Diff line number Diff line change
    @@ -26,6 +26,7 @@ GIT
    [ROLLING BACK A COMMIT] git reset --soft 'HEAD^'

    [DISCARD LAST COMMIT] git reset HEAD --hard
    git reset --hard origin/master

    [ACCEPT THEIRS MERGE] git checkout --theirs

  13. @frangeris frangeris revised this gist Jul 27, 2014. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions git_commands
    Original file line number Diff line number Diff line change
    @@ -6,9 +6,9 @@ GIT

    [DELETE BRANCH UP] git push origin --delete <branchName>

    [TRACK CHANGES] git update-index --assume-unchanged <file>
    [DONT TRACK CHANGES] git update-index --assume-unchanged <file>

    [DONT TRACK CHANGES] git update-index --no-assume-unchanged <file>
    [TRACK CHANGES] git update-index --no-assume-unchanged <file>

    [CLEANING UP CACHE WHEN GIT IGNORE FAIL]
    git rm -r --cached .
  14. @frangeris frangeris revised this gist Jul 25, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git_commands
    Original file line number Diff line number Diff line change
    @@ -17,7 +17,7 @@ GIT

    [CLONE BRANCH] git clone -b <branch> git@<domain>:<user>/<myproject>.git

    [IGNORE MODE] git config core.fileMode false
    [IGNORE MODE FILE] git config core.fileMode false

    [CHECKOUT DOESN'T WORK] git config --global core.autocrlf false

  15. @frangeris frangeris revised this gist Jul 25, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git_commands
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@ GIT

    [DONT TRACK CHANGES] git update-index --no-assume-unchanged <file>

    [CLEANING UP CACHE]
    [CLEANING UP CACHE WHEN GIT IGNORE FAIL]
    git rm -r --cached .
    git add .
    git commit -m "Fixed untracked files"
  16. @frangeris frangeris revised this gist Jul 8, 2014. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions git_commands
    Original file line number Diff line number Diff line change
    @@ -30,3 +30,5 @@ GIT
    [ACCEPT THEIRS MERGE] git checkout --theirs

    [ACCEPT OURS MERGE] git checkout --ours

    [REMOVE REMOTE] git remote rm <remote>
  17. @frangeris frangeris revised this gist May 7, 2014. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions git_commands
    Original file line number Diff line number Diff line change
    @@ -26,3 +26,7 @@ GIT
    [ROLLING BACK A COMMIT] git reset --soft 'HEAD^'

    [DISCARD LAST COMMIT] git reset HEAD --hard

    [ACCEPT THEIRS MERGE] git checkout --theirs

    [ACCEPT OURS MERGE] git checkout --ours
  18. @frangeris frangeris revised this gist Apr 5, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git_commands
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@ GIT

    [DONT TRACK CHANGES] git update-index --no-assume-unchanged <file>

    [.gitignore CLEANING UP]
    [CLEANING UP CACHE]
    git rm -r --cached .
    git add .
    git commit -m "Fixed untracked files"
  19. @frangeris frangeris revised this gist Apr 5, 2014. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions git_commands
    Original file line number Diff line number Diff line change
    @@ -24,3 +24,5 @@ GIT
    [GIT COLOR] git config --global color.ui true

    [ROLLING BACK A COMMIT] git reset --soft 'HEAD^'

    [DISCARD LAST COMMIT] git reset HEAD --hard
  20. @frangeris frangeris revised this gist Mar 24, 2014. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions git_commands
    Original file line number Diff line number Diff line change
    @@ -22,3 +22,5 @@ GIT
    [CHECKOUT DOESN'T WORK] git config --global core.autocrlf false

    [GIT COLOR] git config --global color.ui true

    [ROLLING BACK A COMMIT] git reset --soft 'HEAD^'
  21. @frangeris frangeris revised this gist Mar 24, 2014. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions git_commands
    Original file line number Diff line number Diff line change
    @@ -20,3 +20,5 @@ GIT
    [IGNORE MODE] git config core.fileMode false

    [CHECKOUT DOESN'T WORK] git config --global core.autocrlf false

    [GIT COLOR] git config --global color.ui true
  22. @frangeris frangeris revised this gist Mar 21, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git_commands
    Original file line number Diff line number Diff line change
    @@ -19,4 +19,4 @@ GIT

    [IGNORE MODE] git config core.fileMode false

    [CHECKOUT DO NOT WORK] git config --global core.autocrlf false
    [CHECKOUT DOESN'T WORK] git config --global core.autocrlf false
  23. @frangeris frangeris revised this gist Mar 21, 2014. 1 changed file with 8 additions and 8 deletions.
    16 changes: 8 additions & 8 deletions git_commands
    Original file line number Diff line number Diff line change
    @@ -1,22 +1,22 @@
    GIT
    ===
    [DELETE ALL RM] git rm $(git ls-files --deleted)
    [DELETE ALL RM] git rm $(git ls-files --deleted)

    [DELETE BRANCH DOWN] git branch <branchName> --delete
    [DELETE BRANCH DOWN] git branch <branchName> --delete

    [DELETE BRANCH UP] git push origin --delete <branchName>
    [DELETE BRANCH UP] git push origin --delete <branchName>

    [.gitignore TRACK] git update-index --assume-unchanged <file>
    [TRACK CHANGES] git update-index --assume-unchanged <file>

    [.gitignore DONT] git update-index --no-assume-unchanged <file>
    [DONT TRACK CHANGES] git update-index --no-assume-unchanged <file>

    [.gitignore CLEANING UP]
    git rm -r --cached .
    git add .
    git commit -m "Fixed untracked files"

    [CLONE BRANCH] git clone -b <branch> git@<domain>:<user>/<myproject>.git
    [CLONE BRANCH] git clone -b <branch> git@<domain>:<user>/<myproject>.git

    [IGNORE MODE] git config core.fileMode false
    [IGNORE MODE] git config core.fileMode false

    [CHECKOUT DO NOT WORK] git config --global core.autocrlf false
    [CHECKOUT DO NOT WORK] git config --global core.autocrlf false
  24. @frangeris frangeris revised this gist Mar 21, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git_commands
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@ GIT

    [.gitignore DONT] git update-index --no-assume-unchanged <file>

    [.gitignore]
    [.gitignore CLEANING UP]
    git rm -r --cached .
    git add .
    git commit -m "Fixed untracked files"
  25. @frangeris frangeris revised this gist Mar 21, 2014. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions git_commands
    Original file line number Diff line number Diff line change
    @@ -18,3 +18,5 @@ GIT
    [CLONE BRANCH] git clone -b <branch> git@<domain>:<user>/<myproject>.git

    [IGNORE MODE] git config core.fileMode false

    [CHECKOUT DO NOT WORK] git config --global core.autocrlf false
  26. @frangeris frangeris revised this gist Mar 21, 2014. 1 changed file with 10 additions and 2 deletions.
    12 changes: 10 additions & 2 deletions git_commands
    Original file line number Diff line number Diff line change
    @@ -1,12 +1,20 @@
    GIT
    ===
    [DELETE ALL RM] git rm $(git ls-files --deleted)

    [DELETE BRANCH DOWN] git branch <branchName> --delete

    [DELETE BRANCH UP] git push origin --delete <branchName>

    [.gitignore TRACK] git update-index --assume-unchanged <file>

    [.gitignore DONT] git update-index --no-assume-unchanged <file>

    [.gitignore]
    git rm -r --cached .
    git add .
    git commit -m "fixed untracked files"
    [CLONE BRANCH] git clone -b <branch> git@<domain>:<user>/<myproject>.git
    git commit -m "Fixed untracked files"

    [CLONE BRANCH] git clone -b <branch> git@<domain>:<user>/<myproject>.git

    [IGNORE MODE] git config core.fileMode false
  27. @frangeris frangeris revised this gist Mar 17, 2014. 1 changed file with 5 additions and 5 deletions.
    10 changes: 5 additions & 5 deletions git_commands
    Original file line number Diff line number Diff line change
    @@ -1,12 +1,12 @@
    GIT
    ===
    [DELETE ALL RM] git rm $(git ls-files --deleted)
    [DELETE BRANCH DOWN] git branch <branchName> --delete
    [DELETE BRANCH UP] git push origin --delete <branchName>
    [.gitignore TRACK] git update-index --assume-unchanged <file>
    [DELETE BRANCH DOWN] git branch <branchName> --delete
    [DELETE BRANCH UP] git push origin --delete <branchName>
    [.gitignore TRACK] git update-index --assume-unchanged <file>
    [.gitignore DONT] git update-index --no-assume-unchanged <file>
    [.gitignore]
    git rm -r --cached .
    git add .
    git commit -m "fixed untracked files"
    git add .
    git commit -m "fixed untracked files"
    [CLONE BRANCH] git clone -b <branch> git@<domain>:<user>/<myproject>.git
  28. @frangeris frangeris created this gist Mar 17, 2014.
    12 changes: 12 additions & 0 deletions git_commands
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    GIT
    ===
    [DELETE ALL RM] git rm $(git ls-files --deleted)
    [DELETE BRANCH DOWN] git branch <branchName> --delete
    [DELETE BRANCH UP] git push origin --delete <branchName>
    [.gitignore TRACK] git update-index --assume-unchanged <file>
    [.gitignore DONT] git update-index --no-assume-unchanged <file>
    [.gitignore]
    git rm -r --cached .
    git add .
    git commit -m "fixed untracked files"
    [CLONE BRANCH] git clone -b <branch> git@<domain>:<user>/<myproject>.git