惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园_首页
IT之家
IT之家
博客园 - Franky
Stack Overflow Blog
Stack Overflow Blog
宝玉的分享
宝玉的分享
Recent Announcements
Recent Announcements
Engineering at Meta
Engineering at Meta
S
SegmentFault 最新的问题
V
Visual Studio Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Last Week in AI
Last Week in AI
H
Help Net Security
V
V2EX
H
Hackread – Cybersecurity News, Data Breaches, AI and More
量子位
博客园 - 叶小钗
J
Java Code Geeks
博客园 - 【当耐特】
月光博客
月光博客
爱范儿
爱范儿
人人都是产品经理
人人都是产品经理
酷 壳 – CoolShell
酷 壳 – CoolShell
小众软件
小众软件

Home on Alex Plescan

bigdraw: I made a collaborative drawing site Just for fun: animating a mosaic of 90s GIFs Two computers, one monitor, zero fiddling Placeholder names should be bad and unique Rebuilding this site Okay, I really like WezTerm GNU Parallel, where have you been all my life? Timeseries with PostgreSQL Easy SVG sparklines Using Declarative Shadow DOM to embed HTML emails on a web page Selling SaaS on Gumroad PDF: The Conjoined Triangles of Success Deploying Metabase to Fly.io Xcode 8 managed signing: adding new device UUIDs to a provisioning profile Emojify your Wi-Fi (Netgear R6300 edition) How to use the San Francisco Mono typeface before macOS Sierra is released Disabling App Transport Security in your development environment Swift: A nicer way to tell if your app is running in Debug mode Development environment config overrides in Jekyll Setting up SwiftLint on Travis CI
The ".x" Files
2022-04-17 · via Home on Alex Plescan

💁‍♂️ Here's a tip for a quick way to manage private files in a git repository, using nothing but your shell and git.

In the projects I work on I usually want to have some private files on my local machine that don’t get committed and pushed up to git remotes (i.e. Github) to be seen by my teammates.

These are usually rough little scripts I use during development. For example, I might have this in the root of my repo:

echo "git stash && git checkout main && git pull && npm install && npm dev" > dev.sh

And then add it to the .gitignore :

echo "dev.sh" >> .gitignore

But there’s friction here in a couple of places:

  • I need to remember to add new scripts to the .gitignore each time
  • I’m not being a great teammate by polluting the .gitignore with files that are only relevant on my machine

Enter the “.x” Folder

To improve on that, I’ve started creating an .x folder in my repos’ root and putting all my local-only files there.

I then configure git to ignore any paths matching .x across all repos on my machine.

That means I can put my scripts - or other private files - in the repository’s .x folder, and invoke them like this:

How-to, in detail…

1. Globally ignore “.x” folders from git

Create a .gitignore file in your home directory, and configure git to use it as the default “excludesfile” (git docs).

This will make git apply the exclusions in ~/.gitignore to all repos on your machine.

echo ".x" > ~/.gitignore
git config --global core.excludesfile ~/.gitignore

2. Add local-only files to your repos’ “.x” folders

Add your scripts or anything else you don’t want to commit to the project to the .x folder in your repo.

To implement the example that I gave at the top of this post you could do:

mkdir .x
echo "git stash && git checkout main && git pull && npm install && npm dev" > .x/dev.sh
chmod u+x .x/dev.sh

Scripts tend to be the bulk of what I store in my .x folders, but anything else you don’t want to push up to git remotes can go in there as well.


All done! You can now add all kinds of private files to your .x folder without worrying about them accidentally being uploaded to your git remote!