Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.