Reputation: 751
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?
Upvotes: 1
Views: 75
Reputation: 13743
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://[email protected]/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.
Upvotes: 0
Reputation: 9820
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 README
.
Upvotes: 0
Reputation: 2512
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.
Upvotes: 2
Reputation: 6342
You can add any files you want in your working directory but do NOT want to commit
in a file named .gitignore
Upvotes: 0