You run a 'git status' and see that you've updated a heap of files. One of those files you don't want to commit (often a config). What's the easiest thing to do? Well, I have a few options.
Option 1. Use 'git assume-unchanged'. I have a blog post about that here: https://dev.to/nickraphael/git-assume-unchanged-for-when-you-want-git-to-ignore-an-edit-for-a-while-2lig
Option 2. Just undo you edit before doing the add. Basically using 'git checkout xxx/dontcheckmein.txt'
Option 3. Run a 'git add .' to add all the files. Then run 'git reset -- xxx/dontcheckmein.txt'. This will undo the add.
Then you can 'git commit' to your hearts content.
Top comments (1)
Hey there,
Came across this post as I was searching for a solution to the same problem.
Saw this in StackOverflow:
Now
gitsupportsexclude certain paths and filesby pathspec magic:(exclude)and its short form:!. So you can easily achieve it as the following command.Actually you can specify more:
…The
--option separates theaddcommand from the list of files, so the files won't be mistaken as command-line options. In the case above, all files in the current directory (.), exceptexcludedfile.I've yet to find a documentation for the syntax of the exclusion of files, but I've been using the command and has been working for me (my Git version is 2.20).