I've been playing around with it for a while and I like it very much. Let me describe my case.
I have two computers where I have my repositories and a remote repository.
in my files I have one configuration file which differs on both computers. so when I do pull on my computers I don't need that config file to be pulled, but everything else. How can I achieve that?
I've read about .gitignore files but I can't figure out how they work or are they the thing that I need in my case.
Set “–assume-unchanged” to a path to exclude to check on git commit and it will exclude your file from git commit. You will need to use the git update-index and –assume-unchanged to exclude files from git commit.
gitignore with contents /bin will make it ignore files or folders named bin in th esame folder as the . gitignore . If you want to specify that bin should be a folder, then put a trailing slash. To sum it up, using /bin/ will ignore only the bin folder in the same folder of the .
You just need to add the file to . git/info/exclude in the same way you would add it to . gitignore .
gitignore file is a plain text file where each line contains a pattern for files/directories to ignore. Generally, this is placed in the root folder of the repository, and that's what I recommend. However, you can put it in any folder in the repository and you can also have multiple . gitignore files.
.gitignore is for files/folders that you haven't checked in already. It's essentially a text file that you create in the repository and has a list of paths relative to the directory it was placed in, which Git will ignore. You can check-in the .gitignore file as part of the repository. you can find examples - at the end of this page
However if your file has already been checked in the repository then you can use:
git update-index --assume-unchanged file
which will tell Git to ignore any changes to that file made in the future. However this is a local configuration so you will have to do it on each machine you check out. You can revert it by doing:
git update-index --no-assume-unchanged file
Depending on what configuration that file contains it might be a good practice to have a skeleton/example config file in the repository - similar to what PHP guys do with config_example.php, which then is used by people to create config.php, which in turn never get's checked in the repository because it is ignored.
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