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?

  • How to use Git with two differents repositories with and without ssh authentification?
  • How can I get last commit from GitHub API
  • Capistrano deploy configuration
  • Can git's .gitattributes treat all files as binary except a few exceptions?
  • How can I save an incompletely merged index in git?
  • Cannot find ~/.hgrc file after Mercurial installation via MacPorts
  • how do i search bitbucket files that contain a string and are contained in specific repos?
  • git: merge back in what I merged out
  • Convert git date using GNU date
  • GitHub to Heroku Commit Error
  • Same files listed as both untracked and deleted
  • How could I use git bisect to find the first GOOD commit?
  • 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 README.

    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://git@some.host/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.

    Git Baby is a git and github fan, let's start git clone.