如何在git中找到origin/master的位置,并且如何更改它?

236

我是一个 Git 新手,最近将一个 Rails 项目从 Subversion 迁移到了 Git。我遵循了这里的教程:http://www.simplisticcomplexity.com/2008/03/05/cleanly-migrate-your-subversion-repository-to-a-git-repository/

我还使用 unfuddle.com 存储我的代码。我在通勤途中使用 Mac 笔记本电脑进行更改,然后使用以下命令在拥有网络连接时将它们推送到 unfuddle:

git push unfuddle master

我使用Capistrano进行部署,并从unfuddle存储库使用master分支拉取代码。

最近在我笔记本电脑上运行"git status"时,注意到以下信息:

# On branch master
# Your branch is ahead of 'origin/master' by 11 commits.
#
nothing to commit (working directory clean)

我很困惑为什么会出现这种情况。我原以为是我的笔记本电脑的问题,但不确定是最初从Subversion拉取还是推送到Unfuddle引起了此消息。我该如何:

  1. 找出Git认为“origin/master”在哪里?
  2. 如果它在其他地方,我该如何将我的笔记本电脑变成“origin/master”?
  3. 让这条消息消失。它让我觉得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目录的本地机器上。我相信在将我的项目从 Subversion 转换为 Git 时,gf 是我使用的临时目录,也可能是我从中向 unfuddle 推送的目录。然后我相信我从 unfuddle 检出了一个新副本到geekfor目录。

所以看起来我应该遵循dbr的建议,执行:

git remote rm origin
git remote add origin git@spilth.unfuddle.com:spilth/geekfor.git
13个回答

0

我也正在考虑我的资源库的同样问题。在我的情况下,我有一个旧的远程仓库,我不再推送到它,所以我需要将其删除。

获取远程仓库列表:

git remote

删除您不需要的那个

git remote rm {insert remote to remove}

0

在你自己的提交之前,可以将代码重置到特定的提交。

$ git status
# On branch master
# Your branch is ahead of 'origin/master' by 2 commits.
#
nothing to commit (working directory clean)

使用git log命令查找本地更改之前的提交。
$ git log
commit 3368e1c5b8a47135a34169c885e8dd5ba01af5bb
...
commit baf8d5e7da9e41fcd37d63ae9483ee0b10bfac8e
...

注意本地提交并直接重置到上一个提交:

git reset --hard baf8d5e7da9e41fcd37d63ae9483ee0b10bfac8e

-1
我在将代码推送到远程仓库时遇到了问题:“您的分支领先于 'origin/master' nn 个提交。”
git push ssh://git@xxx.repositryhosting.com/yyy/zzz.git

当我发现我的远程地址在文件.git/FETCH_HEAD中时,我使用了:

git push

问题已经消失。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接