Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
207 views
in Technique[技术] by (71.8m points)

git - 我可以在.gitconfig中为自己指定多个用户吗?(Can I specify multiple users for myself in .gitconfig?)

In my ~/.gitconfig , I list my personal email address under [user] , since that's what I want to use for Github repos.

(在~/.gitconfig ,我在[user]我的个人电子邮件地址,因为这是我要用于Github存储库的地址。)

But, I've recently started using git for work, too.

(但是,我最近也开始使用git进行工作。)

My company's git repo allows me to commit, but when it sends out announcements of new changesets, it says they are from Anonymous because it doesn't recognize the email address in my .gitconfig - at least, that's my theory.

(我公司的git repo允许我提交,但是当它发布新变更集的公告时,它说它们来自匿名用户,因为它无法识别我的.gitconfig的电子邮件地址-至少,这是我的理论。)

Is it possible to specify multiple [user] definitions in .gitconfig ?

(是否可以在.gitconfig指定多个[user]定义?)

Or is there some other way to override the default .gitconfig for a certain directory?

(还是有其他方法可以覆盖某个目录的默认.gitconfig ?)

In my case, I check out all work code in ~/worksrc/ - is there a way to specify a .gitconfig for only that directory (and its subdirectories)?

(就我而言,我在~/worksrc/签出所有工作代码-有没有一种方法可以仅为该目录(及其子目录)指定.gitconfig ?)

  ask by Brock Boland translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can configure an individual repo to use a specific user / email address which overrides the global configuration.

(您可以将单个存储库配置为使用覆盖全局配置的特定用户/电子邮件地址。)

From the root of the repo, run

(从仓库的根开始,运行)

git config user.name "Your Name Here"
git config user.email [email protected]

whereas the default user / email is configured in your ~/.gitconfig

(而默认用户/电子邮件是在您的?/ .gitconfig中配置的)

git config --global user.name "Your Name Here"
git config --global user.email [email protected]

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...