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:
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.
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.
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.
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.
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.
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.
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.
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.
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:
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With