2015-07-16 2 views
6

मैंने इसी तरह के प्रश्न पर अन्य प्रश्नों को देखा है।सभी रिमोट शाखा कैसे प्राप्त करें, "गिट fetch --all" काम नहीं करता

लेकिन ऐसा लगता है कि उत्तर git fetch --all है।

लेकिन मेरे मामले में, यह काम नहीं करता है।

यही वह है जो मैंने इसके लिए किया है।

> git branch 
* master 

> git branch -r 
origin/master 
origin/A 

> git fetch --all 
> git branch 
* master  #still not updated 

> git fetch origin/A 
fatal: 'origin/A' does not appear to be a git repository 
fatal: Could not read from remote repository. 

Please make sure you have the correct access rights 
and the repository exists. 

> git fetch remotes/origin/A 
fatal: 'origin/A' does not appear to be a git repository 
fatal: Could not read from remote repository. 

Please make sure you have the correct access rights 
and the repository exists. 

और मैंने git pull --all भी कोशिश की लेकिन परिणाम भी वही है।

------------------- संपादित -------------------

> git pull --all 
Already up-to-date. 

> git branch 
* master    # I think it should show branch A also 

> git remote show origin 
HEAD branch: master 
Remote branches: 
    A  tracked 
    master tracked 

------------------- संपादित -------------------

> git pull origin A 
* branch   A  -> FETCH_HEAD 
Already up-to-date. 

> git branch 
* master     # I think it should show barnch A also 
+2

1. यह 'गिट फ़ेच मूल' ए 'गिट फ़ेच मूल/ए' नहीं है। 2. 'गिट पुल' एक 'fetch' और 'विलय' करेगा। 'git pull --all' को सभी ** ट्रैक की गई ** शाखाओं पर एक पुल करना चाहिए। – noahnu

+0

आपके संपादन से, ऐसा लगता है कि यह काम कर रहा है। समस्या क्या है? – noahnu

+0

@noahnu मुझे लगता है कि 'गिट शाखा' को 'शाखा ए' के ​​साथ-साथ 'मास्टर' दिखाना चाहिए। – SangminKim

उत्तर

6

git branch केवल स्थानीय शाखाएं प्रदर्शित करता है। git branch -r रिमोट शाखाएं प्रदर्शित करेगा, जैसा कि आपने स्वयं के लिए देखा है।

git branch 
*master 

git branch -r 
origin/master 
origin/A 

git fetch --all सूची आप देख जब आप लिखते हैं git branch -r अपडेट करेगा, लेकिन यह इसी स्थानीय शाखाओं नहीं बनाएगा।

आप जो करना चाहते हैं वह शाखाओं की जांच करना है। यह रिमोट शाखा की एक स्थानीय प्रतिलिपि बना देगा और अपस्ट्रीम को रिमोट पर सेट करेगा।

git checkout -b mylocal origin/A 

git branch 
master 
*mylocal 

git branch -r 
origin/master 
origin/A 

mylocal इस मामले में origin/A है। -b पैरामीटर बनने के बाद नई शाखा में स्विच हो जाएगा। आप बस टाइप कर सकते हैं: git checkout A नई शाखा का स्वतः नाम देगा।

0

आपको स्थानीय स्तर पर भी लांच की गई शाखा बनाने की आवश्यकता है:

git fetch --all && git checkout A 
1

मुझे लगता है कि आप वास्तव में क्या देख रहे हैं git branch -a कमांड है। यह सभी स्थानीय और दूरस्थ शाखाओं को दिखाएगा। यहां एक उदाहरण दिया गया है:

# Only show local branches 
$ git branch 
* master 
    develop 

# Only show remote branches 
$ git branch -r 
    origin/HEAD -> origin/master 
    origin/master 
    origin/develop 
    origin/foo 

# Show both local and remote branches 
$ git branch -a 
* master 
    develop 
    remotes/origin/HEAD -> origin/master 
    remotes/origin/master 
    remotes/origin/develop 
    remotes/origin/foo 

आप देखेंगे कि सभी शाखाएं हैं - आदेश स्थानीय और दूरस्थ दोनों शाखाएं दिखाएगा।

foo शाखा केवल रिमोट पर निकलती है, मेरे पास स्थानीय foo शाखा नहीं है।

# Create a local 'foo' branch from the remote one 
$ git checkout foo 
Branch foo set up to track remote branch foo from origin. 
Switched to a new branch 'foo' 

# Show both local and remote branches 
$ git branch -a 
* foo 
    master 
    develop 
    remotes/origin/HEAD -> origin/master 
    remotes/origin/master 
    remotes/origin/develop 
    remotes/origin/foo 

यह वही है आप स्थानीय रूप से देख रहे हैं की व्याख्या करनी चाहिए: एक स्थानीय foo शाखा बनाने के लिए, मैं checkout आदेश का प्रयोग करेंगे।

संबंधित मुद्दे