I have some files (documentaion, utility scripts, private key to my server etc) in repository which don't have to be in deployment but it has to be in repo for development convienience. Is there any way like .gitignore to ignore some files and folders while pulling?
Asked
Active
Viewed 39 times
0
-
No there isn't, but maybe you'll find the answer to this question useful? [How to git-pull all but one folder](https://stackoverflow.com/questions/2416815/how-to-git-pull-all-but-one-folder) – Daemon Painter May 12 '20 at 08:09
-
Sounds like an unusual approach. Where are you pulling and why don't you want the files to be present? Maybe think about adding a "compile" step to put together a distribution, which you can install. For example, if you use your repo to host files of a website, use a script to put together everything needed for deployment. – Sebi May 12 '20 at 08:55
-
Note that `git pull` means *run `git fetch`, then run a second Git command*. The `git fetch` step never touches *any* of your working tree files *at all*. It's the *second* Git command that is of interest, so your question should be rephrased as "is there a way to get
not to – torek May 12 '20 at 17:42some files". You can choose either merge or rebase as your second command ... but the thing is, there's still no really good way to make `git merge` not merge some files, or `git rebase` not to rebase some files. -
1None of this makes any sense until you realize that these files aren't even *in* Git at all. Then, once you realize that your work-tree is *yours* and Git just messes with it when you ask Git to mess with it, and that both `git merge` and `git rebase` explicitly ask Git to mess with it, it starts to make sense. – torek May 12 '20 at 17:43
-
It's usually much better *not* to put configurations and things like private keys into repositories at all. You can put "sample" files in, so that an initial clone provides the samples, which can be renamed to be the real files. Then the real files are never stored in any commit, and therefore Git never needs to mess with them. – torek May 12 '20 at 17:45
1 Answers
0
As I know there is no such command for pulling. But you can customize your editor environment to hide this kind of files. I'm using VS code and in user setting I just added code below which is telling to ignore and hide this folders, files for me.
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true,
"**/yarn.lock": true,
"node_modules/": true
},

Sabit Rakhim
- 460
- 3
- 12