gitignore

How to ignore files which are in repository?

Deadly 提交于 2019-11-28 15:22:26
I have a file (config.php), that is already commited to Git repository, but I want to ignore locally, i.e. I want that file to remain in repository, but force Git to ignore any changes to it. I put the file into .gitignore, but it is still marked as changed and Git still is attempting to commit changes to it, every time I commit something. Any idea, what am I missing or doing wrong? If the file is still displayed in the status, even though it is in the .gitignore, make sure it isn't already tracked. git rm --cached config.php If you just want to ignore it locally, you could also make it

.gitignore exclude files in directory but not certain directories

拟墨画扇 提交于 2019-11-28 15:11:17
application/cache/* application/cache/folder/* application/cache/folder/onemorefolder/* This doesn't seem to be working. When I clone the project, there is no "application/cache" folder or "application/cache/folder" folder, etc... I'd like if files in the cache folders weren't cached but folders were, so that the folders permissions transfer and exist. Git doesn't track folders, only files, so if you ignore everything in a folder, Git won't have anything to track. You can add a .gitignore file to each directory ( application/cache , application/cache/folder , application/cache/folder

Is there a way to tell git to only include certain files instead of ignoring certain files?

﹥>﹥吖頭↗ 提交于 2019-11-28 15:09:25
My programs generally generate huge output files (~1 GB) which I do not want to be backing up to the git repository. So instead of being able to do git add . I have to do something like git add *.c *.cc *.f *.F *.C *.h *.cu which is a little bit cumbersome... I feel fairly confident I could write a quicky perl script ls the directory contents into .gitignore and then remove files based on a .gitinclude (or some similar name) file, but that seems a little too hackish. Is there a better way? I haven't had need to try this myself, but from my reading of TFM it looks like a negated pattern would

Where does the .gitignore file belong?

本小妞迷上赌 提交于 2019-11-28 15:01:34
Does the .gitignore file belong in the .git folder structure somewhere or in the main source files? Put .gitignore in the working directory. It doesn't work if you put it in the .git (repository) directory. $ ls -1d .git* .git .gitignore As the other answers stated, you can place .gitignore within any directory in a Git repository. However, if you need to have a private version of .gitignore , you can add the rules to .git/info/exclude file. You can place .gitignore in any directory in git. It's commonly used as a placeholder file in folders, since folders aren't usually tracked by git. Hraban

git still shows files as modified after adding to .gitignore

谁都会走 提交于 2019-11-28 14:59:50
i'm adding this to .gitignore file .idea/* but anyway the status is: # modified: .gitignore # modified: .idea/.generators # modified: .idea/dovezu.iml # modified: .idea/misc.xml # modified: .idea/workspace.xml what am i doing wrong ? i even added .idea/* to the global ~/.gitignore_global but git status, anyway shows me: # modified: .gitignore # modified: .idea/.generators # modified: .idea/dovezu.iml # modified: .idea/misc.xml # modified: .idea/workspace.xml Your .gitignore is working, but it still tracks the files because they were already in the index. To stop this you have to do : git rm -r

Remove file from the repository but keep it locally

亡梦爱人 提交于 2019-11-28 14:56:15
I have a folder which I'd like to remove in my remote repository. I'd like to delete it, but keep the folder in my computer git rm --cached -r somedir Will stage the deletion of the directory, but doesn't touch anything on disk. This works also for a file, like: git rm --cached somefile.ext Afterwards you may want to add somedir/ or somefile.ext to your .gitignore file so that git doesn't try to add it back. I would just: Move the folder out of your working tree git rm the folder, commit the change Add to .gitignore (or .git/info/excludes ), commit the change Move the folder back 来源: https:/

How to tell git to ignore all further edit to a single file without removing it from the repo

断了今生、忘了曾经 提交于 2019-11-28 14:41:46
问题 I have forked a project on github and started messing around with it on my own machine, I want to commit the changes I have made back to my fork on github but without commiting the changes I have made to the .cfg file, since this contains things like db password etc 回答1: Use this: git update-index --skip-worktree path/file.cfg And to restore: git update-index --no-skip-worktree path/file.cfg Lastly, if you want to list files that are marked with skip-worktree : git ls-files -v | grep ^S | awk

When to use leading slash in gitignore

天涯浪子 提交于 2019-11-28 14:21:59
问题 I'm trying to understand more clearly the .gitignore syntax, and in particular as far as https://github.com/github/gitignore gitignores are concerned. I see that the leading slash is used to match only pathnames relative to the location of the .gitignore file (from http://git-scm.com/docs/gitignore): A leading slash matches the beginning of the pathname. For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c". But what happens when i remove the leading slash? As far as what i

Add newly created specific folder to .gitignore in Git

谁说胖子不能爱 提交于 2019-11-28 14:09:04
问题 I had a clean working directory and brought in a clone from a Git repo last night. But now my local server created and contains a stats folder which I want to ignore. I can't seem to get Git to ignore this folder when I run a git status. On branch master Your branch is ahead of 'origin/master' by 1 commit. Changes to be committed: (use "git reset HEAD <file>..." to unstage) new file: app_public/views/pages/privacy.php new file: app_public/views/pages/terms.php new file: public_html/stats/ctry

Git is ignoring .idea folder, but that isn't in gitignore

你说的曾经没有我的故事 提交于 2019-11-28 13:37:19
The problem: I'm on OSX. I have a very small .gitignore file, and I even tried completely deleting the file. Nothing helps. Git doesn't see anything under my .idea directory for intellij. At the very least I want to store .idea/runConfigurations/*. Worse than that, according to this post , all the files in that directory but 1 or 2 should be source controlled. Is there an extra, hidden .gitignore setting somewhere I don't know about? Is there any way to search for and murder it if so? Steps taken so far: I manually added the most important ones with: git add .idea/runConfigurations -f Trying