gitignore

How to tell git to ignore individual lines, i.e. gitignore for specific lines of code [duplicate]

眉间皱痕 提交于 2019-11-26 05:54:58
问题 This question already has an answer here: Can git ignore a specific line? 8 answers .gitignore can ignore whole files, but is there a way to ignore specific lines of code while coding? I frequently and repeatedly add the same debug lines in a project, only to have to remember to remove them before committing. I\'d like to just keep the lines in the code and have git disregard them. 回答1: This is how you can kind of do it with git filters: Create/Open gitattributes file: <project root>/

Ignoring directories in Git repositories on Windows

若如初见. 提交于 2019-11-26 05:49:02
问题 How can I ignore directories or folders in Git using msysgit on Windows? 回答1: Create a file named .gitignore in your project's directory. Ignore directories by entering the directory name into the file (with a slash appended): dir_to_ignore/ More information is here. 回答2: By default, Windows Explorer will display .gitignore when in fact the file name is .gitignore.txt . Git will not use .gitignore.txt And you can't rename the file to .gitignore , because Explorer thinks it's a file of type

How do negated patterns work in .gitignore?

风格不统一 提交于 2019-11-26 05:29:33
问题 I am attempting to use a .gitignore file with negated patterns (lines starting with !), but it\'s not working the way I expect. As a minimal example, I have the folllowing directory structure: C:/gittest -- .gitignore -- aaa/ -- bbb/ -- file.txt -- ccc/ -- otherfile.txt and in my gitignore file, I have this: aaa/ !aaa/ccc/ My understanding (based on this doc page) is that the file aaa/ccc/otherfile.txt should not be ignored, but in fact git is ignoring everything under aaa. Am I

How do .gitignore exclusion rules actually work?

岁酱吖の 提交于 2019-11-26 04:38:26
问题 I\'m trying to solve a gitignore problem on a large directory structure, but to simplify my question I have reduced it to the following. I have the following directory structure of two files (foo, bar) in a brand new git repository (no commits so far): a/b/c/foo a/b/c/bar Obviously, a \'git status -u\' shows: # Untracked files: ... # a/b/c/bar # a/b/c/foo What I want to do is create a .gitignore file that ignores everything inside a/b/c but does not ignore the file \'foo\'. If I create a

gitignore all files of extension in directory

那年仲夏 提交于 2019-11-26 04:37:23
问题 Is there a way to ignore all files of a type in a directory? ** is apparently meaningless to git, so this doesn\'t work: /public/static/**/*.js The idea is to match arbitrary nested folders. 回答1: Never tried it, but git help ignore suggests that if you put a .gitignore with *.js in /public/static , it will do what you want. Note: make sure to also check out Joeys' answer below: if you want to ignore files in a specific subdirectory, then a local .gitignore is the right solution (locality is

Remove directory from remote repository after adding them to .gitignore

白昼怎懂夜的黑 提交于 2019-11-26 04:28:46
问题 I committed and pushed some directory to github. After that, I altered the .gitignore file adding a directory that should be ignored. Everything works fine, but the (now ignored) directory stays on github. How do I delete that directory from github and the repository history? 回答1: The rules in your .gitignore file only apply to untracked files. Since the files under that directory were already committed in your repository, you have to unstage them, create a commit, and push that to GitHub:

How do I add files without dots in them (all extension-less files) to the gitignore file?

不想你离开。 提交于 2019-11-26 04:18:39
问题 Like the title says, is it possible to add \"files without dots in them\" to the gitignore file? I imagine this would take care of all those bothersome extensionless files. 回答1: You can try a combination similar to: * !/**/ !*.* That gitignore exclusion rule (a negated pattern) should ignore all files, except the ones with an extension. As mentioned below by Mad Physicist, the rule is: It is not possible to re-include a file if a parent directory of that file is excluded. ( * ) ( * : unless

.gitignore after commit

故事扮演 提交于 2019-11-26 03:47:31
问题 I have a git repository hosted on Github. After committing many files, I am realizing that I need to create .gitignore and exclude .exe , .obj files. However, will it automatically remove these committed files from the repository? Is there any way to force that? 回答1: No you cannot force a file that is already committed in the repo to be removed just because it is added to the .gitignore You have to git rm --cached to remove the files that you don't want in the repo. ( --cached since you

How to create a .gitignore file

喜你入骨 提交于 2019-11-26 03:46:02
问题 I need to add some rules to my .gitignore file. However, I can\'t find it in my project folder. Isn\'t it created automatically by Xcode? If not, what command allows me to create one? 回答1: If you're using Windows it will not let you create a file without a filename in Windows Explorer. It will give you the error " You must type a file name " if you try to rename a text file as .gitignore To get around this I used the following steps Create the text file gitignore.txt Open it in a text editor

What are the differences between .gitignore and .gitkeep?

有些话、适合烂在心里 提交于 2019-11-26 03:36:25
问题 What are the differences between .gitignore and .gitkeep ? Are they the same thing with a different name, or do they both serve a different function? I don\'t seem to be able to find much documentation on .gitkeep . 回答1: .gitkeep isn’t documented, because it’s not a feature of Git. Git cannot add a completely empty directory. People who want to track empty directories in Git have created the convention of putting files called .gitkeep in these directories. The file could be called anything;