Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make Git temporarily ignore ~/.gitconfig?

Tags:

git

How can I make a Git command temporarily ignore my ~/.gitconfig?

I can set GIT_CONFIG=/dev/null to make git config ignore ~/.gitconfig, but this doesn't affect other Git commands.

I can hide my ~/.gitconfig, e.g. mv ~/.gitconfig{,.hidden}, but this is annoying since I have to move it back later and it affects Git globally.

Use Cases

  • Scripting Git: restrict to default settings for portability.
  • Debugging Git: restrict to default settings for reproducibility.
like image 457
ntc2 Avatar asked May 01 '14 00:05

ntc2


People also ask

How do I set git permission to ignore changes?

If you set core. filemode=false then git will ignore execute bit changes, no need to change local permissions. Unless you've already added permission changes to the index, in which case you're missing the step where you would need to git add after you turn off core.

How do I ignore a local file in git?

If you want to ignore certain files in a repository locally and not make the file part of any repository, edit . git/info/exclude inside your repository.

What is Gitconfig file?

The git config command is a convenience function that is used to set Git configuration values on a global or local project level. These configuration levels correspond to . gitconfig text files. Executing git config will modify a configuration text file.

What is ignoreCase in git?

core.ignoreCase. If true, this option enables various workarounds to enable Git to work better on filesystems that are not case sensitive, like FAT. For example, if a directory listing finds "makefile" when Git expects "Makefile", Git will assume it is really the same file, and continue to remember it as "Makefile".


1 Answers

I found a decent workaround: Git can't use my ~/.gitconfig if it can't find it:

HOME= git <args>

works! Here HOME= effectively unsets HOME for the duration of the command git <args>.

More careful but longer versions include

HOME=/dev/null git <args>

and

(unset HOME; git <args>)
like image 147
ntc2 Avatar answered Oct 29 '22 23:10

ntc2