最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

What happened to git pull --all and how do I achieve the same effect? - Stack Overflow

programmeradmin3浏览0评论

Here's my directory structure:

root
|
\- GitRepoA
\- GitRepoB
\- GitRepoC
...
\- GitRepoN

I'm trying to effectively git pull master or git pull main in each of my git repos. Some of them use master, some use main.

I've found multiple answers to this question that should solve my problem: How do I fetch all Git branches? But they're all laden with git pull --all, and I can't find anything about --all existing for the pull command.

What happened to git pull --all and how do I achieve the same outcome it would have given me?

Here's my directory structure:

root
|
\- GitRepoA
\- GitRepoB
\- GitRepoC
...
\- GitRepoN

I'm trying to effectively git pull master or git pull main in each of my git repos. Some of them use master, some use main.

I've found multiple answers to this question that should solve my problem: How do I fetch all Git branches? But they're all laden with git pull --all, and I can't find anything about --all existing for the pull command.

What happened to git pull --all and how do I achieve the same outcome it would have given me?

Share Improve this question edited Mar 18 at 7:25 dani-vta 7,5357 gold badges49 silver badges65 bronze badges asked Mar 17 at 21:23 Daniel KaplanDaniel Kaplan 67.7k57 gold badges270 silver badges403 bronze badges 8
  • 4 What /is/ the behaviour you expect? – Ulrich Eckhardt Commented Mar 17 at 21:34
  • 1 git pull --all means git fetch --all + git merge; see git-scm/docs/git-pull#_description): "More precisely, git pull runs git fetch with the given parameters and then depending on configuration options or command line flags, will call either git rebase or git merge to reconcile diverging branches." – phd Commented Mar 18 at 6:50
  • 4 Please everyone be warned that unlike git push --all which means "push all branches" git fetch --all doesn't mean "fetch all branches"! It means "fetch all remotes"! – phd Commented Mar 18 at 6:50
  • 1 The option --all in git pull and git fetch means all remotes. The default remote is origin. – ElpieKay Commented Mar 18 at 7:06
  • 1 @DanielKaplan Well, I don't remember; I use Git for quite some time, regularly read and re-read docs, visit SO a few times a day and learn from questions and great answers. git help help, git help git, git help fetch, git help pull, git help push – phd Commented Mar 20 at 20:15
 |  Show 3 more comments

1 Answer 1

Reset to default 4

The git pull option --all was present up to Git 2.43.1. According to the release notes of Git 2.44.0, the flag --all was removed, as the config variable fetch.all should be favored.

"git fetch" learned to pay attention to "fetch.all" configuration variable, which pretends as if "--all" was passed from the command line when no remote parameter was given.

In your case, in order to fetch from all available remotes, just set the config variable fetch.all to true.

If true, fetch will attempt to update all available remotes. This behavior can be overridden by passing --no-all or by explicitly specifying one or more remote(s) to fetch from. Defaults to false.

# setting the config variable to fetch from all remotes
git config --local fetch.all true

# fetching from all available remotes
git pull

Alternatively, if you do no want to leave fetch.all to true, and wish to have it enabled only when you want to pull from all remotes, you could define an alias as a workaround to temporarily set fetch.all to true, pull from all remotes, and then reset the variable again.

# define the alias
git config --local alias.pull-all '!sh -c "git config --local fetch.all true && git pull || git config --local fetch.all false"'

# pull from all remotes
git pull-all
发布评论

评论列表(0)

  1. 暂无评论