gitignore

Remove directory from remote repository after adding them to .gitignore

佐手、 提交于 2019-11-26 16:50:29
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? Mark Longair 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: git rm -r --cached some-directory git commit -m 'Remove the now ignored directory "some-directory

Exclude specific files from 'git pull'

╄→гoц情女王★ 提交于 2019-11-26 16:13:32
问题 I have a production git repo that I only pull changes from the main repo into; I never change this repo or do commits/pushes from here. I recently accidentally pushed some untracked (at least I thought they were) image files to the main repo from my local dev repo. Now when I try to pull the latest from the main repo, git reports an error regarding overwriting the exiting image file with the file from the main repo. I don't even want this file from the repo (it's located in a ,gitignored

gitignore all files of extension in directory

心已入冬 提交于 2019-11-26 15:50:44
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. 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 good). However if you need the same pattern to apply to your whole repo, then the ** solution is better.

How do .gitignore exclusion rules actually work?

柔情痞子 提交于 2019-11-26 15:48:22
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 thus: c/ Then a 'git status -u' shows both foo and bar as ignored: # Untracked files: ... #

Commit empty folder structure (with git) [duplicate]

非 Y 不嫁゛ 提交于 2019-11-26 15:27:20
问题 This question already has an answer here: How can I add an empty directory to a Git repository? 33 answers I have data directory in project's root. It has images directory and some files. Here is example: data ├── images │ ├── image1.jpg │ ├── image2.jpg │ └── image3.jpg ├── results.csv └── r.txt What to write in gitignore, to ignore files from data/ directory (that is results.csv and r.txt) and files from images/ directory (image.jpg, image2.jpg, image3.jpg)? When I commit it, folder

When would you use .git/info/exclude instead of .gitignore to exclude files?

眉间皱痕 提交于 2019-11-26 15:14:43
问题 I am a bit confused about the pros and cons of using .git/info/exclude and .gitignore to exclude files. Both of them are at the level of the repository/project, so how do they differ and when should we use .git/info/exclude ? 回答1: The advantage of .gitignore is that it can be checked into the repository itself, unlike .git/info/exclude . Another advantage is that you can have multiple .gitignore files, one inside each directory/subdirectory for directory specific ignore rules, unlike .git

gitignore does not ignore folder

十年热恋 提交于 2019-11-26 15:11:45
问题 In the root of my project I have a foo folder. Inside the foo folder I have a bar folder. I would like to ignore all changes to all files inside my bar folder. I have this in my gitignore : /foo/bar The folder is checked: it exists and it has the files to be ignored. gitignore is commit ted. However, I have a file where I make a moification and is inside my bar folder. When I type git status inside my git bash I see the file which should have been ignored. What could be the reason and how can

Git: How to remove file from index without deleting files from any repository

て烟熏妆下的殇ゞ 提交于 2019-11-26 15:00:02
问题 When you use git rm --cached myfile it doesn't delete from the local filesystem, which is the goal. But if you've already versioned and committed the file, pushed it to a central repository, and pulled it into yet another repository before using the command, it will delete the file from that system. Is there a way to just remove the file from versioning without deleting it from any filesystem? Edit: Clarified, I hope. 回答1: I do not think a Git commit can record an intention like “stop

Apply .gitignore on an existing repository already tracking large number of files

五迷三道 提交于 2019-11-26 14:57:35
问题 I have an existing Visual Studio project in my repository. I recently added a .gitignore file under my project and I assume that tells Git to ignore the files listed in the file. My problem is that all those files are already being tracked and as far as I know Git will not ignore a file that was already tracked before a rule was added to this file to ignore it. It was suggested to use: git rm --cached and manually un-track them but that's going to take me forever to go through them one by one

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

放肆的年华 提交于 2019-11-26 14:53:15
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. Kache This is how you can kind of do it with git filters : Create/Open gitattributes file: <project root>/.gitattributes (will be committed into repo) OR <project root>/.git/info/attributes (won't be committed into