如何覆盖.git / config中设置的[remote“origin”] url? 有时我需要使用https协议,我的用户名和密码作为网址的一部分,我不想提交此类信息。 一种选择是忽略.git / config。 有办法: a)覆盖它(来自全局.gitconfig?),或 b)有一个本地的.git / config但不用担心它可以被提交,或者 d)有一个别名来git push https://privateurl master ,或者 c)让它以其他方式工作吗?
How to override [remote "origin"] url set in .git/config? Sometimes I need to use an https protocol with my username and password as part of the url and I wouldn't like to commit such information. One option is to ignore .git/config. Is there a way to: a) override it (from global .gitconfig?), or b) have a local .git/config but without worrying it could be commited, or d) have an alias to git push https://privateurl master, or c) have it working in some other way?
最满意答案
我认为你误解了Git是如何工作的。 .git目录中的文件存储Git需要操作的信息。 这包括存储库信息(提交,对象,指针等)以及元信息(本地索引,本地首选项等)。 .git目录中的文件不存储在存储库中,因为它们本质上是存储库。 元信息(例如.git / config中的设置)不会被推送到远程存储库。
有关.git目录的(简要)概述,请参阅Git社区手册中的此条目,以及此问题以供进一步讨论。
I think you are misunderstanding how Git works. The files in your .git directory store the information Git needs to operate. This includes repository information (commits, objects, pointers etc) as well as meta information (the local index, local preferences and so on). Files inside the .git directory aren't stored in the repository, as they essentially are the repository. Meta information (such as settings in .git/config) will not be pushed to remote repositories.
See this entry in the Git Community Book for a (brief) overview of the .git directory, and this question for further discussion.
更多推荐
发布评论