English 中文(简体)
如何确定您的缺省边远盖存放处?
原标题:How to determine your default remote git repository?

How can I see the default remote repository set on my Pycharm? I want to know when I type git push without specifying the repository name, which of my remote repository is going to be updated, assuming that I have added multiple remote repository with different alias names.

问题回答

查阅违约上游储存库时,可使用<代码>git config-ed。

这表明您的宝藏是如何建立的。

在处长办公室之下,你想要检查距离,有一条线:remote = 例。 查阅该档案中的边远名称,你可以发现,什么东西会从哪里寄出/丢失。

为了将违约情况推向遥远,您可使用https://git-scm.com/docs/git-for-each-ref#Documentation/git-for-each-ref.txt-push” rel=“nofollow noreferer”>>。 格式:

git for-each-ref --format= %(push:remotename)  $(git symbolic-ref HEAD)

为从远处拉走,请打电话https://git-scm.com/docs/git-for-each-ref#Documentation/git-for-each-ref.txt-upstream”rel=“nofollow noreferer”>。 格式:

git for-each-ref --format= %(upstream:remotename)  $(git symbolic-ref HEAD)

您也可使用<代码>git Branch——list ,但在某种程度上,这一条略微慢(0.1s vs 0.2s on my organ)。


(原始答复如下)

It seems like git ls-remote --get-url is the command. It prints URL instead of the remote name, but it was sufficient in my case. git ls-remote assumes the default remote if you don t provide one, so you can get the default remote URL with it. The doc was not very clear about the usage though.

www.un.org/spanish/ecosoc Edit:push/code>到上文更好的备选办法。

To answer the first question, it depends mainly on the setting of your remote repository.

在某些第三方网站,如ith光或bit光上,你可以将一些分支定为“<>受保护的<>/em>,这意味着任何推动都将遭到拒绝,迫使任何人利用拉动要求合并任何内容。

由于这一限制,你可以推向任何部门,无论是否主人。 在此情况下,你确实把当地推向遥远。

BEST: git push/pull --dry-run -v

略微大意如此,但最有可能实际上回答“违约的边远存放处是什么?”

$>  git push --dry-run -v
Pushing to REMOTE-URL-OR-PATH
To REMOTE-URL-OR-PATH
 = [up to date]        master -> master
Everything up-to-date

$>  git pull --dry-run -v
From REMOTE-URL-OR-PATH
 = [up to date]  master       -> remote_repo/master
 = [up to date]  other-branch -> remote_repo/remote-name-for-branch

Almost as good: git branch -vv & git remote show <remote>

<代码>git Branch -vv和git rural show <remote>是“我如何确定违约的偏远存放处”问题的几乎答案。

<代码>git Branch -vv 不妨:

* master         41af0b6f [remote_repo/master]  commit message
  other-branch   1d9eb2e6 [remote_repo/branch-name-on-remote] blah blah

您可从<代码>git 边远-v找到远距的URLs或途径。

不幸的是,<代码>git Branch -vv没有告诉你你,如果你有单独的违约要求推动和支付费用。

。 例如,见以下产出。

虽然你可以尝试阅读REPO/.git/config或git config --edit——但一般而言,有许多不同的选择和缺省组合使你的眼球融化。

TL;DR - i.e. excessive detail required because AFAIK there is no perfect answer

答案很晚,我有同样的问题。 部分可能是BKM(最知名的方法),或至少是回答这一问题的相当好的方法,分散在 st流和许多不同网站的处所。 其中许多分散的部分是不正确的,回答诸如“我如何改变违约的边远存放处?”的问题,而不是“我如何告诉违约的边远存放处是什么? 在这方面,似乎也发生了相当大的变化,增加了各种强盗指挥的新选择。 这很可能是重复的,或已在别处得到答复,但这是我在这方面发现的最简明的问题。

首先,“违约偏僻”的概念实际上属于每个分支,而不是每个存放处。 (尽管有某种组合方式,以便所有布置的存放处在设定价值后都出现同样的违约情况。) 远处。

Read git config yourself :-(

因此,你可以总是通过“git configedit”或手工编辑Your-GIT-REPO-ROOT/config来查阅你的集邮档案,寻找像样的 st。

[branch "master"]
    remote = some_repo
    merge = refs/heads/master
[remote "some_repo"]
    url = ...
    fetch = +refs/heads/*:refs/remotes/some_repo/*

然而,由于人们往往想在任何特定部门中作出不同的推卸和推推卸,因此,这已变得更加困难。 因此,你可能会看到像在混淆档案中那样的条目。

[remote "<name>"]
        url = <URL>
        pushurl = <pushurl>
        push = <refspec>
        fetch = <refspec>

或者通过重述等方法确定这种选择

remote.<branch>.pushDefault

branch.<name>.remote <-- remote.pushDefault --> <name>.pushRemote. 

branch.<name>.pushRemote --overrides--> branch.<name>.remote and remote.pushDefault 

branch.<name>.merge ---> branch.<name>.remote

如果你没有发现上述情况,或有时甚至没有发现,那么特别的“原始”可能或不可能用来确定你将推动或退出哪里。

BTW虽然有诸如推波夫和推土等混杂的选择,但并没有真正的选择,如拉夫诺。 由于拖拉确实是 g的,然后是merge,如果你真的想要 hand倒一切,则寻找fetch的备选办法。

! 地球资源中心是养家糊口的人,他们说“我眼球被粉碎”。

Anyway: while you can try reading your configuration, if several or many of the above configuration options are in use it can be quite difficult to determine exactly where your pushes and pulls will go to by default. Although most repositories will only have a restricted configuration, it is easy for a long-lived repository to accumulate craft that makes it difficult. IMHO the best way to determine where your pushes and pulls go is to run code on an actual computer, not simulate it in your head.

git branch -vv - better, but does not understand push/pull separation

最近的我实际上已经找到了一种自动的方法,来确定一个分支的违约推动和拉动到什么地方:git Branch -v,其文件载于。 说:

-v -vv --verbose

When in list mode, show sha1 and commit subject line for each head, along with relationship to upstream branch (if any). If given twice, print the path of the linked worktree (if any) and the name of the upstream branch, as well (see also git remote show <remote>). ....

<代码>git Branch -vv 不妨:

* master         41af0b6f [remote_repo/master]  commit message
  other-branch   1d9eb2e6 [remote_repo/branch-name-on-remote] blah blah

边远地点是边远存放地名称的地方名称,常常是“原始”但可能还有东西。

And you can map the local name for the remote repository to its URL or filesystem pathname by git remote -v

不幸的是,这一版本的<代码>git Branch -v只了解“上游分支的名称”,没有处理推波/波拉/什么情况? 存在不同的违约情况。

git remote show <remote> - better, but maps wrong way

git remote show <remote> provides a lot more info, including push/pull distinction - but AFAICT it only handles one <remote> at a time, so you might have to iterate over all the remotes in your repo.

* remote onedrive_repo
  Fetch URL: ...
  Push  URL: ...
  HEAD branch: master
  Remote branches:
    master        tracked
    some-other    tracked
  Local branches configured for  git pull :
    master           merges with remote master
    other-branch     merges with remote branch_name_on_remote
  Local refs configured for  git push :
    master           pushes to master                  (up to date)
    other-branch     pushes to branch_name_on_remote

--dry-run and --verbose options are your friends

BEST: git push/pull --dry-run -v

如果你只想问问这个问题,我几乎想说——也许最好的办法。 实际也是正确的。

$>  git push --dry-run -v
Pushing to REMOTE-URL-OR-PATH
To REMOTE-URL-OR-PATH
 = [up to date]        master -> master
Everything up-to-date

$>  git pull --dry-run -v
From REMOTE-URL-OR-PATH
 = [up to date]  master       -> remote_repo/master
 = [up to date]  other-branch -> remote_repo/remote-name-for-branch

Are we done yet? No... submodules

下面是另一个问题。 我在这里胜过。 页: 1 您再次是朋友。





相关问题
git confusion - cloning a repo is returning a past version

Im having some confusion with my git usage. I cloned a repo from one comp to the other, and the new clone is the state of the original that was active some time ago. So its cloning a past version. ...

Appropriate strategy for tagging and hotfixing with git

I was wondering if the strategy I m using for tagging and hotfixing tags (which then I use for deploying rails applications) with git is appropriate. For tagging I just tag a commit of the master ...

Tips on upgrading CVS to git/hg?

We still use CVS, I use git and hg for my personal use though I m still a novice at both, but I realize they re much more modern and better, faster, distributed, etc. It s just everyone is so ...

Using Git in a TFS shop

Using Git at home has spoiled me - I now find using TFS at work to be a bit of a drag and want to explore the possibility of using Git locally and syncing somehow with TFS. I figure there are a few ...

热门标签