我如何在git中找到origin / master的位置,以及如何更改它? [英] How can I find the location of origin/master in git, and how do I change it?

查看:2309
本文介绍了我如何在git中找到origin / master的位置,以及如何更改它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是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进行部署并从解压存储库中提取代码使用master分支。



最近,我在笔记本电脑上运行git status时发现了以下消息:

 #分支大师
#你的分支在11次提交之前领先于'origin / master'。
$
没有提交(工作目录干净)

而我困惑为什么。我认为我的笔记本电脑是原产地......但不知道我最初从Subversion提取或推到Unfuddle的事实是什么导致该消息出现。我怎么能:


  1. 找出Git认为'origin / master'的地方是什么?

  2. If它在别的地方,我怎么把我的笔记本电脑变成'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':无法chdir或不是git存档
致命:远程端意外挂起

当我按照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时可能使用的临时目录,可能是我从中推断出来的。然后我相信我检出了一个新鲜的副本,从unfuddle到 geekfor 目录。



所以看起来我应该按照dbr的建议做:

  git remote rm origin 
git remote add origin git@spilth.unfuddle.com: spilth / geekfor.git


解决方案


1。找出Git认为'origin / master'正在使用的位置



pre> git remote show origin

..这会返回一些东西like ..

  *远程原点
网址:me@remote.example.com:〜/ something.git
远程分支与分支主设备上的'git pull'合并
master
跟踪远程分支
master

遥控器基本上是遥控器的链接ository。当你做...

  git remote add unfuddle me@unfuddle.com/myrepo.git 
git push unfuddle

git会将更改推送到您添加的地址。它就像一个书签,用于远程存储库。



运行 git status 时,它会检查远程是否丢失提交(与本地存储库相比),如果是,则提交多少次提交。如果您将所有更改都推送到原产地,两者都将同步,因此您不会收到该消息。


2。如果它在别的地方,我怎么把我的笔记本电脑变成'origin / master'?



这样做没有意义。说起源重新命名为笔记本电脑 - 你永远不想在你的笔记本电脑上执行 git push laptop

如果你想删除远程源,你可以做。

  git remote rm origin 

这不会删除任何东西(根据文件内容/修订历史记录)。这将停止你的分支在...之前的消息,因为它不再将你的仓库与远程仓库进行比较(因为它已经不存在了!)

请记住, origin 没有什么特别之处,它只是git使用的默认名称。



Git使用 git pull > git pull 默认情况下,当您执行 git push > git pull >。所以,如果你有一个遥控器使用了很多(在你的情况下,Unfuddle),我会建议添加unfuddle作为原点:

  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 unfuddle master


I'm a Git newbie. I recently moved a Rails project from Subversion to Git. I followed the tutorial here: http://www.simplisticcomplexity.com/2008/03/05/cleanly-migrate-your-subversion-repository-to-a-git-repository/

I am also using unfuddle.com to store my code. I make changes on my Mac laptop on the train to/from work and then push them to unfuddle when I have a network connection using the following command:

git push unfuddle master

I use Capistrano for deployments and pull code from the unfuddle repository using the master branch.

Lately I've noticed the following message when I run "git status" on my laptop:

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

And I'm confused as to why. I thought my laptop was the origin... but don't know if either the fact that I originally pulled from Subversion or push to Unfuddle is what's causing the message to show up. How can I:

  1. Find out where Git thinks 'origin/master' is?
  2. If it's somewhere else, how do I turn my laptop into the 'origin/master'?
  3. Get this message to go away. It makes me think Git is unhappy about something.

My mac is running Git version 1.6.0.1.


When I run git remote show origin as suggested by dbr, I get the following:

~/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

When I run git remote -v as suggested by Aristotle Pagaltzis, I get the following:

~/Projects/GeekFor/geekfor 10:33 AM $ git remote -v
origin  /Users/brian/Projects/GeekFor/gf/.git
unfuddle    git@spilth.unfuddle.com:spilth/geekfor.git

Now, interestingly, I'm working on my project in the geekfor directory but it says my origin is my local machine in the gf directory. I believe gf was the temporary directory I used when converting my project from Subversion to Git and probably where I pushed to unfuddle from. Then I believe I checked out a fresh copy from unfuddle to the geekfor directory.

So it looks like I should follow dbr's advice and do:

git remote rm origin
git remote add origin git@spilth.unfuddle.com:spilth/geekfor.git

解决方案

1. Find out where Git thinks 'origin/master' is using git-remote

git remote show origin

..which will return something like..

* remote origin
  URL: me@remote.example.com:~/something.git
  Remote branch merged with 'git pull' while on branch master
    master
  Tracked remote branch
    master

A remote is basically a link to a remote repository. When you do..

git remote add unfuddle me@unfuddle.com/myrepo.git
git push unfuddle

..git will push changes to that address you added. It's like a bookmark, for remote repositories.

When you run git status, it checks if the remote is missing commits (compared to your local repository), and if so, by how many commits. If you push all your changes to "origin", both will be in sync, so you wont get that message.

2. If it's somewhere else, how do I turn my laptop into the 'origin/master'?

There is no point in doing this. Say "origin" is renamed to "laptop" - you never want to do git push laptop from your laptop.

If you want to remove the origin remote, you do..

git remote rm origin

This wont delete anything (in terms of file-content/revisions-history). This will stop the "your branch is ahead by.." message, as it will no longer compare your repository with the remote (because it's gone!)

One thing to remember is that there is nothing special about origin, it's just a default name git uses.

Git does use origin by default when you do things like git push or git pull. So, if you have a remote you use a lot (Unfuddle, in your case), I would recommend adding unfuddle as "origin":

git remote rm origin
git remote add origin git@subdomain.unfuddle.com:subdomain/abbreviation.git

or do the above in one command using set-url:

git remote set-url origin git@subdomain.unfuddle.com:subdomain/abbreviation.git

Then you can simply do git push or git pull to update, instead of git push unfuddle master

这篇关于我如何在git中找到origin / master的位置,以及如何更改它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆