Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: File that must be distributed, but ignored / not reuploaded? [duplicate]

Possible Duplicate:
git: can i commit a file and ignore the content changes?

I have a simple problem, and I hope there's a simple solution.

Using Git (and Tower, great app), I have a repository that has a file that everyone needs to download when they clone the repo, BUT that file should never be reuploaded with changes (because it's a configurtion file, with database-specific usernames / passwords, and paths) - the changes are made only when used locally.

What I want to do is ignore whatever change I made locally to that file, so the file won't get updated when I push changes to my repo. How can this be achieved?

It should be noted that:

  1. When I clone the repo, the file shows up, but when I ignore it (local only, not via .gitignore) I have to untrack it, and when I do and push changes back to the server, anyone that clones the repo will NOT download the file << undesired behavior.

  2. If I ignore the file but I DON'T untrack it, the file still shows up in my working directory, waiting to be commited << undesired behavior.

like image 459
AeroCross Avatar asked Apr 07 '11 19:04

AeroCross


People also ask

How to make a file ignored by Git?

If you want to ignore a file that you've committed in the past, you'll need to delete the file from your repository and then add a . gitignore rule for it. Using the --cached option with git rm means that the file will be deleted from your repository, but will remain in your working directory as an ignored file.

Where Git ignore file?

gitignore file tells Git which files to ignore when committing your project to the GitHub repository. gitignore is located in the root directory of your repo. / will ignore directories with the name.

How can I ignore files that have already been committed to the repo?

Git can only ignore files that are untracked - files that haven't been committed to the repository, yet. That's why, when you create a new repository, you should also create a . gitignore file with all the file patterns you want to ignore.

What's gitignore?

gitignore file is a text file that tells Git which files or folders to ignore in a project. A local . gitignore file is usually placed in the root directory of a project. You can also create a global . gitignore file and any entries in that file will be ignored in all of your Git repositories.

What is the use of Git ignore in Git?

Git can specify which files or parts of your project should be ignored by Git using a .gitignore file. Git will not track files and folders specified in .gitignore. However, the .gitignore file itself IS tracked by Git.

Why doesn't Git ignore all files in SRC/Dist?

My .gitignore file should be ignoring all files in src/dist, but isn't. If you already added those files and git is tracking them, the .gitignore file has no effect because it is meant for untracked files. See a good solution here: stackoverflow.com/a/23673910/2430526 .gitignore only ignores files that are not part of the repository yet.

How to ignore all temp files in a git repository?

These kinds of ignores are specified in the .git/info/exclude file. It works the same way as .gitignore but are not shown to anyone else. In .gitignore add a line to ignore all .temp files:

How do I exclude a specific file from a git repository?

Use your favorite text editor to open the file called .git/info/exclude within the root of your Git repository. Any rule you add here will not be checked in, and will only ignore files for your local repository. Git Bash. Navigate to the location of your Git repository. Using your favorite text editor, open the file .git/info/exclude.


1 Answers

Commit an example file, gitignore the real name, and have your contributors copy the example into the proper location, then configure it. Alternately, provide a setup script that copies the example and does those steps.

like image 136
Daenyth Avatar answered Oct 12 '22 11:10

Daenyth