我是Git新手。我最近把一个Rails项目从Subversion转移到Git。我遵循了这里的教程:http://www.simplisticcomplexity.com/2008/03/05/cleanly-migrate-your-subversion-repository-to-a-git-repository/
我还使用unfuddle.com来存储我的代码。我在上班/下班的火车上对我的Mac笔记本电脑进行更改,然后在我有网络连接时,使用以下命令将它们推到不稳定状态:
git push unfuddle master
我使用Capistrano进行部署,并使用主分支从unduddle存储库中提取代码。
最近,当我在笔记本电脑上运行“git status”时,我注意到下面的消息:
# On branch master
# Your branch is ahead of 'origin/master' by 11 commits.
#
nothing to commit (working directory clean)
我很困惑为什么。我以为我的笔记本电脑是源头…但不知道是否我最初从Subversion或推送到unduddle是导致消息显示的原因。我怎样才能:
找出Git认为“源/主”在哪里?
如果是在其他地方,我如何把我的笔记本电脑变成“源/主”?
让这条信息消失。这让我觉得Git对某些事情不满意。
我的mac运行的是Git 1.6.0.1版本。
当我按照dbr的建议运行git remote show origin时,我得到以下结果:
~/Projects/GeekFor/geekfor 10:47 AM $ git remote show origin
fatal: '/Users/brian/Projects/GeekFor/gf/.git': unable to chdir or not a git archive
fatal: The remote end hung up unexpectedly
当我按照Aristotle Pagaltzis的建议运行git remote -v时,我得到以下结果:
~/Projects/GeekFor/geekfor 10:33 AM $ git remote -v
origin /Users/brian/Projects/GeekFor/gf/.git
unfuddle git@spilth.unfuddle.com:spilth/geekfor.git
现在,有趣的是,我在geekfor目录中处理我的项目,但它说我的原点是gf目录中的本地机器。我相信gf是我在将项目从Subversion转换到Git时使用的临时目录,可能也是我从那里推送到unduddle的地方。然后我相信我检查了一个新的副本从unuddle到geekfor目录。
所以看起来我应该遵循dbr的建议,这样做:
git remote rm origin
git remote add origin git@spilth.unfuddle.com:spilth/geekfor.git
1. 用Git -remote找出Git认为“origin/master”在哪里
git remote show origin
..它将返回类似于..
* remote origin
URL: me@remote.example.com:~/something.git
Remote branch merged with 'git pull' while on branch master
master
Tracked remote branch
master
远程基本上就是到远程存储库的链接。当你…
git remote add unfuddle me@unfuddle.com/myrepo.git
git push unfuddle
..Git会将更改推送到您添加的地址。它就像一个书签,用于远程存储库。
当您运行git status时,它会检查远程存储库是否缺少提交(与本地存储库相比),如果是,则检查提交的数量。如果你把所有的更改都推到“原点”,两者都会同步,所以你不会收到那个消息。
2. 如果是在其他地方,我如何把我的笔记本电脑变成“源/主”?
这样做毫无意义。说“origin”被重命名为“laptop”-你永远不想从你的笔记本电脑上做git push laptop。
如果你想删除原始远程,你可以这样做。
git remote rm origin
这不会删除任何东西(在文件-内容/修订-历史方面)。这将停止“您的分支领先于..”消息,因为它将不再将您的存储库与远程存储库进行比较(因为它已经消失了!)
有一件事要记住,关于origin没有什么特别的,它只是git使用的默认名称。
当你执行Git push或Git pull之类的操作时,Git默认使用origin。所以,如果你有一个经常使用的遥控器(在你的情况下是unuddle),我建议添加unuddle作为“origin”:
git remote rm origin
git remote add origin git@subdomain.unfuddle.com:subdomain/abbreviation.git
或者使用set-url在一个命令中执行上述操作:
git remote set-url origin git@subdomain.unfuddle.com:subdomain/abbreviation.git
然后你可以简单地做git push或git pull来更新,而不是git push unuddle master
1. 用Git -remote找出Git认为“origin/master”在哪里
git remote show origin
..它将返回类似于..
* remote origin
URL: me@remote.example.com:~/something.git
Remote branch merged with 'git pull' while on branch master
master
Tracked remote branch
master
远程基本上就是到远程存储库的链接。当你…
git remote add unfuddle me@unfuddle.com/myrepo.git
git push unfuddle
..Git会将更改推送到您添加的地址。它就像一个书签,用于远程存储库。
当您运行git status时,它会检查远程存储库是否缺少提交(与本地存储库相比),如果是,则检查提交的数量。如果你把所有的更改都推到“原点”,两者都会同步,所以你不会收到那个消息。
2. 如果是在其他地方,我如何把我的笔记本电脑变成“源/主”?
这样做毫无意义。说“origin”被重命名为“laptop”-你永远不想从你的笔记本电脑上做git push laptop。
如果你想删除原始远程,你可以这样做。
git remote rm origin
这不会删除任何东西(在文件-内容/修订-历史方面)。这将停止“您的分支领先于..”消息,因为它将不再将您的存储库与远程存储库进行比较(因为它已经消失了!)
有一件事要记住,关于origin没有什么特别的,它只是git使用的默认名称。
当你执行Git push或Git pull之类的操作时,Git默认使用origin。所以,如果你有一个经常使用的遥控器(在你的情况下是unuddle),我建议添加unuddle作为“origin”:
git remote rm origin
git remote add origin git@subdomain.unfuddle.com:subdomain/abbreviation.git
或者使用set-url在一个命令中执行上述操作:
git remote set-url origin git@subdomain.unfuddle.com:subdomain/abbreviation.git
然后你可以简单地做git push或git pull来更新,而不是git push unuddle master