Skip to content

Instantly share code, notes, and snippets.

@weirdpattern
Created November 13, 2018 18:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save weirdpattern/d89812d518fc5bc9161b4a420391c701 to your computer and use it in GitHub Desktop.
Save weirdpattern/d89812d518fc5bc9161b4a420391c701 to your computer and use it in GitHub Desktop.
2018.11.13.stash-all-changes
# adds a new file
$ touch file.txt
# update .gitignore to include file.txt
$ "file.txt" > .gitignore
# get the status
$ git status
On branch master
Your branch is up to date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: .gitignore
no changes added to commit (use "git add" and/or "git commit -a")
# stash changes (stashes .gitignore and file.txt)
$ git stash --all
# get the status
$ git status
On branch master
Your branch is up to date with 'origin/master'.
nothing to commit, working tree clean
# adds a new file
$ touch file.txt
# update .gitignore to include file.txt
$ "file.txt" > .gitignore
# get the status
$ git status
On branch master
Your branch is up to date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: .gitignore
no changes added to commit (use "git add" and/or "git commit -a")
# stash changes (stashes .gitignore, file.txt becomes available as it's no longer ignored)
$ git stash --include-untracked
# get the status
$ git status
On branch master
Your branch is up to date with 'origin/master'.
Untracked files:
(use "git add <file>..." to include in what will be committed)
file.txt
nothing added to commit but untracked files present (use "git add" to track)
# stash everything (tracked, untracked, ignored)
git stash --all
# stash everything, (tracked and untracked, but not ignored)
git stash [save -u | --include-untracked]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment