Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: How to prevent committing files that were modified just for debugging purposes?

Tags:

git

perforce

A lot of times, I like to modify some lines of code in order to make debugging easier, but I don't actually want to commit them. For instance, I'll disable some annoying features (like ads) by commenting out some lines of code, or I'll set the log levels and filters to only the ones I care about, or I'll force a conditional to be true just so the block of code I want to run actually runs all the time.

In Perforce, I would have created a "changelist" for these files and labeled it as "DON'T COMMIT!". What would be the equivalent of this in Git? A branch doesn't work because these debug-only modifications need to exist with other changes I'm currently making.

like image 951
thien Avatar asked Apr 19 '12 00:04

thien


People also ask

What changes are not staged commit?

The “changes not staged for commit” message shows when you run the “git status” command and have a file that has been changed but has not yet been added to the staging area. This is not an error message, rather a notification that you have changed files that are not in the staging area or a commit.

What is stage changes in git?

The "Staging Area" In Git, just because a file was modified doesn't mean it will be automatically included in the next commit. Instead, you have to tell Git explicitly which of your modifications shall be part of the next commit. This is done by adding a change to the Staging Area or, put simply, by "staging" it.


1 Answers

Lookup the --assume-unchanged option. There is a blog article about this which explains things quite well. And also this one which mentions finding such ignored files later on.

like image 53
patthoyts Avatar answered Oct 16 '22 14:10

patthoyts