2013-10-11 79 views
0

我使用hub创造命令GitHub的仓库,如何为git存储库设置默认的远程原点?

git create -d "Some description" 

但不问我,它会自动添加oldUser/repo.git为远程,因为我不再使用oldUser作为我的github帐户,怎么能我更改此默认行为newUser/repo.git

回答

2

卸载并重新安装应该可行,但你也可以尝试这样的事情在~/.config/hub

--- 
github.com: 
- user: new_user 
+0

没有,但我觉得有像修改配置文件 – mko

+0

@yozloy看到我更新一个更简单的方法。 – Dennis

+0

工程就像一个魅力!谢谢 ! – mko

0

Git附带了一个名为git config的工具,可以让您获取和设置配置变量,以控制Git的外观和操作方式。这些变量可以存储在三个不同的地方:

/etc/gitconfig file: Contains values for every user on the system and all their repositories. If you pass the option--system to git config, it reads and writes from this file specifically. 

~/.gitconfig file: Specific to your user. You can make Git read and write to this file specifically by passing the --global option. 

config file in the git directory (that is, .git/config) of whatever repository you’re currently using: Specific to that single repository. Each level overrides values in the previous level, so values in .git/config trump those in /etc/gitconfig. 

在Windows系统上,Git会查找在$ HOME目录中的.gitconfig文件(在Windows的环境下%USERPROFILE%),这是C:\ Documents和Settings \ $ USER或C:\ Users \ $ USER,这取决于版本($ USER是Windows环境中的%USERNAME%)。它仍然在寻找/ etc/gitconfig,尽管它与MSys根有关,无论你决定在运行安装程序时在Windows系统上安装Git的位置。

您的标识 安装Git时应该做的第一件事是设置您的用户名和电子邮件地址。这是重要的,因为每一个git的承诺使用此信息,并且它是不可改变烤成提交您绕过:

$ git config --global user.name "John Doe" 
$ git config --global user.email [email protected] 

同样,你需要做的这只,如果你传递--global选项一次,因为那时的Git将始终将该信息用于您在该系统上执行的任何操作。如果您想用特定项目的不同名称或电子邮件地址覆盖此项,则可以在该项目中运行不带--global选项的命令。

您的编辑 现在您的身份已设置,您可以配置Git需要您输入消息时将使用的默认文本编辑器。默认情况下,Git使用您系统的默认编辑器,通常是Vi或Vim。如果你想使用一个不同的文本编辑器,例如Emacs,你可以做到以下几点:

$ git config --global core.editor emacs 

你的比较工具 您可能需要配置另一个有用的选项是用来解决合并冲突默认比较工具。说你想用Vimdiff:

$ git config --global merge.tool vimdiff 

的Git接受kdiff3,tkdiff,合并,xxdiff,出现,vimdiff同时,gvimdiff,ecmerge,并作为了opendiff有效合并工具。您还可以设置一个自定义工具;请参阅第7章获取更多信息。

检查您的设置 如果要检查您的设置,您可以使用混帐配置--list命令列出所有设置的Git可以发现在这一点上:

$ git config --list 
user.name=Scott Chacon 
[email protected] 
color.status=auto 
color.branch=auto 
color.interactive=auto 
color.diff=auto 
... 

您可能会看到更多的键因为Git从不同的文件(例如/ etc/gitconfig和〜/ .gitconfig)读取相同的密钥。在这种情况下,Git使用它看到的每个唯一键的最后一个值。

您还可以检查什么混帐认为特定键的值是通过键入混帐配置{键}:

$ git config user.name 
Scott Chacon 
相关问题