git untracked files that are needed
So in my directory, there’s a config file specific to the machine that I don’t want to track for my git repo. But the problem is, I need that file to test my app, so when I pull that repo or create a branch, I would need to backup and add that config file to the directory manually. Anyone had a problem like this and can provide a solution?
4 Solutions collect form web for “git untracked files that are needed”
Generally, I would add an example config file to the git repository and then copy it and modify the values that are specific to a machine or a development environment.
This approach is also useful when don’t want the sensitive information like the password or API keys version controlled.
You can add any files you want in your working directory but do NOT want to
commit in a file named .gitignore
Is there any reason why adding it to your
.gitignore will not work for you?
The file will remain on your machine but will not be tracked by git. If someone pulls your repo, you will need to instruct them to create this file if it’s necessary to run your app.
You could do this in your
Well, first, you’re asking git to do something it does not do. That’s like being angry that when you copy a directory on your system, cp doesn’t automatically know to go copy files out of a different directory and add them to the destination. It just doesn’t make sense.
The simplest solution would be just to setup a shell script or alias which does what you want.
alias clone_repo="git clone ssh://firstname.lastname@example.org/git.repo /Users/bob/my_repo && cp /Users/bob/my_saved_config_file.txt /Users/bob/my_repo"
As a fancier solution, git hooks are shell scripts. Presumably, you could write a post-clone hook to create the file. However, you’d have to clone with the –template switch.