Git config:私有远程网址(Git config: private remote url)

系统教程 行业动态 更新时间:2024-06-14 16:57:40
Git config:私有远程网址(Git config: private remote url)

如何覆盖.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.

更多推荐

本文发布于:2023-04-13 12:14:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/952a6857b037aebd55b970ca49709874.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:网址   config   Git   url   remote

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!