繁体   English   中英

如何获得 Git 本地分支机构的列表,这些分支机构尚未推送到 GitHub?

[英]How can I get a list of Git local branches, which are not already pushed to GitHub?

鉴于:

  • 我在当地有一些分支机构,其中一些被推送到我的帐户到 GitHub
  • 但有一些我没有推过的当地分支机构

如何列出未推送的分支?

也可能:

列出现有远程可见的所有本地分支(推送/非推送)。

我已经尝试了命令remote show origin并且在那里我看到了远程分支,但是有未列出的本地未推送分支:(

git remote -v show origin

这仅显示我的本地分支机构:

git branch -vv

添加于 2020-05-06:

预期结果:

我看到我所有的本地分支机构都有相关的原始分支机构:

注意:此预期结果是手动创建的

* master                               [origin/master: 60 hinterher]
  muescha/feature/npm-readme
  muescha/fix/agility-format           [origin/muescha/fix/agility-format: ... ]
  muescha/fix/anchor-tags-in-glossary
  muescha/fix/brand-webpack            [origin/muescha/fix/brand-webpack: ... ]
  muescha/fix/claudinary-code-block
  muescha/fix/claudinary-format
  muescha/fix/claudinary-optional
  muescha/fix/docs-bash-to-shell       [origin/muescha/fix/docs-bash-to-shell: ... ]
  muescha/fix/gatsby-cloud-brand-names
  muescha/fix/la-days-kim              [origin/muescha/fix/la-days-kim: ... ]
  muescha/fix/receipes-changes
  muescha/fix/tutorials-1-8
  muescha/fix/tutorials-1-8-fix        [origin/muescha/fix/tutorials-1-8-fix: ... ]

这样我就可以看到哪个分支还没有被推送到 GitHub。

在我的例子中,这些分支机构在 GitHub 上没有分支机构,只有本地分支机构:

注意:此预期结果是手动创建的

  muescha/feature/npm-readme
  muescha/fix/anchor-tags-in-glossary
  muescha/fix/claudinary-code-block
  muescha/fix/claudinary-format
  muescha/fix/claudinary-optional
  muescha/fix/gatsby-cloud-brand-names
  muescha/fix/receipes-changes
  muescha/fix/tutorials-1-8

当前状态:

分行GitHub

https://github.com/muescha/gatsby/branches

# Default branch
master                         | Updated 2 days ago by wardpeet   | Default

# Your branches
muescha/fix/la-days-kim        | Updated 16 days ago by muescha   | 288/3
muescha/fix/docs-bash-to-shell | Updated 14 days ago by gatsbybot | 187/7
muescha/fix/brand-webpack      | Updated 12 days ago by gatsbybot | 127/4
muescha/fix/agility-format     | Updated 20 days ago by muescha   | 288/4
muescha/fix/tutorials-1-8-fix  | Updated 2 months ago by muescha  | 901/1

git 远程--详细

$ git remote --verbose
gatsby    https://github.com/gatsbyjs/gatsby.git (fetch)
gatsby    https://github.com/gatsbyjs/gatsby.git (push)
origin    https://github.com/muescha/gatsby.git (fetch)
origin    https://github.com/muescha/gatsby.git (push)

git 配置--本地-l

$ git config --local -l
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
core.ignorecase=true
core.precomposeunicode=true
remote.origin.url=https://github.com/muescha/gatsby.git
remote.origin.fetch=+refs/heads/master:refs/remotes/origin/master
remote.gatsby.url=https://github.com/gatsbyjs/gatsby.git
remote.gatsby.fetch=+refs/heads/*:refs/remotes/gatsby/*
pull.rebase=true
branch.muescha/fix/tutorials-1-8-fix.remote=origin
branch.muescha/fix/tutorials-1-8-fix.merge=refs/heads/muescha/fix/tutorials-1-8-fix
branch.master.remote=origin
branch.master.merge=refs/heads/master
branch.muescha/fix/docs-bash-to-shell.remote=origin
branch.muescha/fix/docs-bash-to-shell.merge=refs/heads/muescha/fix/docs-bash-to-shell
branch.muescha/fix/brand-webpack.remote=origin
branch.muescha/fix/brand-webpack.merge=refs/heads/muescha/fix/brand-webpack
branch.muescha/fix/la-days-kim.remote=origin
branch.muescha/fix/la-days-kim.merge=refs/heads/muescha/fix/la-days-kim
branch.muescha/fix/agility-format.remote=origin
branch.muescha/fix/agility-format.merge=refs/heads/muescha/fix/agility-format

git 分支-vv

$ git branch -vv
* master                               5a4f7a1e7 [origin/master: 60 hinterher] chore(starters): add gatsby-typescript-starter-minimalist (#23393)
  muescha/feature/npm-readme           f07b4db3c fix brand names
  muescha/fix/agility-format           06d9f8ad0 fix add language to code block
  muescha/fix/anchor-tags-in-glossary  505e5268e fixes links
  muescha/fix/brand-webpack            d0758d81f change brand names in yaml files
  muescha/fix/claudinary-code-block    b6eca1f0f fix add language to code block
  muescha/fix/claudinary-format        546fbdfc5 fix move out of prefix section
  muescha/fix/claudinary-optional      03d41affc fix move other optionals out of prefix section
  muescha/fix/docs-bash-to-shell       df7ad898c add shell
  muescha/fix/gatsby-cloud-brand-names cad8ed156 fix brand names
  muescha/fix/la-days-kim              623c6d28c change tags indent
  muescha/fix/receipes-changes         f788c2d0d change brand names, local links
  muescha/fix/tutorials-1-8            bf1eb90a1 chore(gatsby-source-filesystem): fix jdoc (#22197)
  muescha/fix/tutorials-1-8-fix        17dac01b7 fix

git 分支-avv

$ git branch -avv
* master                                                                   5a4f7a1e7 [origin/master: 60 hinterher] chore(starters): add gatsby-typescript-starter-minimalist (#23393)
  muescha/feature/npm-readme                                               f07b4db3c fix brand names
  muescha/fix/agility-format                                               06d9f8ad0 fix add language to code block
  muescha/fix/anchor-tags-in-glossary                                      505e5268e fixes links
  muescha/fix/brand-webpack                                                d0758d81f change brand names in yaml files
  muescha/fix/claudinary-code-block                                        b6eca1f0f fix add language to code block
  muescha/fix/claudinary-format                                            546fbdfc5 fix move out of prefix section
  muescha/fix/claudinary-optional                                          03d41affc fix move other optionals out of prefix section
  muescha/fix/docs-bash-to-shell                                           df7ad898c add shell
  muescha/fix/gatsby-cloud-brand-names                                     cad8ed156 fix brand names
  muescha/fix/la-days-kim                                                  623c6d28c change tags indent
  muescha/fix/receipes-changes                                             f788c2d0d change brand names, local links
  muescha/fix/tutorials-1-8                                                bf1eb90a1 chore(gatsby-source-filesystem): fix jdoc (#22197)
  muescha/fix/tutorials-1-8-fix                                            17dac01b7 fix
  remotes/gatsby/100days-challenge-12                                      7f744f9e6 Fix typo
  remotes/gatsby/100days-challenge-12-branch                               7095e418b Expand on stale handling for gatsby sites (#22230)
  remotes/gatsby/100days-challenge-13                                      b08657ec8 Draft challenge 13
  remotes/gatsby/7z                                                        165bc0f09 restore apt install for circle, hopefully cloud wont randomly fail this time
  remotes/gatsby/Aswinpookkatt-patch-5                                     8a162cd2c fixed minor issue in docs
  remotes/gatsby/Blog-post-porting-jekyll-to-gatsby                        03e304ff2 �
  remotes/gatsby/DaleSeo-patch-1                                           5c577b6c3 Fix the image path
  remotes/gatsby/DaleSeo-patch-1-1                                         86c6bf76b Update remark-plugin-tutorial.md
  remotes/gatsby/KyleAMathews-patch-1                                      16010754d feat(gatsby-recipes): document option support for GatsbyPlugin
  remotes/gatsby/KyleAMathews-patch-2                                      2e40b6deb Update packages/gatsby-recipes/README.md
  remotes/gatsby/NotMoni-fix-whitespace                                    f2d27e72b fix whitespace
  remotes/gatsby/Olanetsoft-patch-2                                        2381fea7d Updated read-me with punctuation where necessary
  remotes/gatsby/PaulinaVPG/master                                         2f623924d Tested tutorial and left a few suggestions
  remotes/gatsby/Rizwanjamal-patch-1                                       6de1fbd25 docs: remove hidden code that no longer seen
  remotes/gatsby/Rizwanjamal-patch-1-1                                     618d4c642 docs: remove dead code
...
...
...

git remote -v show origin

$ git remote -v show origin
* Remote-Repository origin
  URL zum Abholen: https://github.com/muescha/gatsby.git
  URL zum Versenden: https://github.com/muescha/gatsby.git
  Hauptbranch: master
  Remote-Branch:
    master gefolgt
  Lokale Branches konfiguriert für 'git pull':
    master                         führt mit Remote-Branch master zusammen
    muescha/fix/agility-format     führt mit Remote-Branch muescha/fix/agility-format zusammen
    muescha/fix/brand-webpack      führt mit Remote-Branch muescha/fix/brand-webpack zusammen
    muescha/fix/docs-bash-to-shell führt mit Remote-Branch muescha/fix/docs-bash-to-shell zusammen
    muescha/fix/la-days-kim        führt mit Remote-Branch muescha/fix/la-days-kim zusammen
    muescha/fix/tutorials-1-8-fix  führt mit Remote-Branch muescha/fix/tutorials-1-8-fix zusammen
  Lokale Referenzen konfiguriert für 'git push':
    master                         versendet nach master                         (lokal nicht aktuell)
    muescha/fix/agility-format     versendet nach muescha/fix/agility-format     (aktuell)
    muescha/fix/brand-webpack      versendet nach muescha/fix/brand-webpack      (lokal nicht aktuell)
    muescha/fix/docs-bash-to-shell versendet nach muescha/fix/docs-bash-to-shell (lokal nicht aktuell)
    muescha/fix/la-days-kim        versendet nach muescha/fix/la-days-kim        (aktuell)
    muescha/fix/tutorials-1-8-fix  versendet nach muescha/fix/tutorials-1-8-fix  (aktuell)

git 日志源/master..HEAD

$ git log origin/master..HEAD
# no output

git 日志 --branches --not --remotes

$ git log --branches --not --remotes

commit 623c6d28c2792a24b147501a3e9e878aac54b04e (muescha/fix/la-days-kim)
Author: Muescha <184316+muescha@users.noreply.github.com>
Date:   Mon Apr 20 23:20:10 2020 +0200

    change tags indent

commit df7ad898c3149362bc385a427298cf3ad8431d63 (muescha/fix/docs-bash-to-shell)
Author: Muescha <184316+muescha@users.noreply.github.com>
Date:   Sun Apr 19 17:19:50 2020 +0200

    add shell

commit d0758d81f83c9a5e8ef5f1d1fb42f415bd6c9c4f (muescha/fix/brand-webpack)
Author: Muescha <184316+muescha@users.noreply.github.com>
Date:   Sat Apr 18 16:00:01 2020 +0200

    change brand names in yaml files

commit f788c2d0d472b62ce663a21e4d1a154fcde700ad (muescha/fix/receipes-changes)
Author: Muescha <184316+muescha@users.noreply.github.com>
Date:   Sat Apr 18 15:54:12 2020 +0200

    change brand names, local links

commit 06d9f8ad0853450c3dc7efc131331ca5da312e2f (muescha/fix/agility-format)
Author: Muescha <184316+muescha@users.noreply.github.com>
Date:   Thu Apr 16 15:19:36 2020 +0200

    fix add language to code block

commit b6eca1f0fb7cef6c8cbb937fd92a477220bdbbcb (muescha/fix/claudinary-code-block)
Author: Muescha <184316+muescha@users.noreply.github.com>
Date:   Thu Apr 16 08:58:38 2020 +0200

    fix add language to code block

commit 03d41affcd116272edb74961a6fae1c5e55ecf51 (muescha/fix/claudinary-optional)
Author: Muescha <184316+muescha@users.noreply.github.com>
Date:   Thu Apr 16 07:26:04 2020 +0200

    fix move other optionals out of prefix section

commit 546fbdfc58f7158b24507a6cbc73a70184c98e6c (muescha/fix/claudinary-format)
Author: Muescha <184316+muescha@users.noreply.github.com>
Date:   Thu Apr 16 07:23:43 2020 +0200

    fix move out of prefix section

commit 461e45ccb4e66c9b34ab857b4f14aaf973f3fe99
Author: Muescha <184316+muescha@users.noreply.github.com>
Date:   Thu Apr 16 07:16:59 2020 +0200

    fix for lint/prettier

commit f07b4db3cf5ce3f78410db132892c8c99e9ca8b0 (muescha/feature/npm-readme)
Author: Muescha <184316+muescha@users.noreply.github.com>
Date:   Thu Apr 16 05:02:49 2020 +0200

    fix brand names

commit cad8ed156f712f774c7f31a8c6c340cdc1ce2a22 (muescha/fix/gatsby-cloud-brand-names)
Author: Muescha <184316+muescha@users.noreply.github.com>
Date:   Thu Apr 16 04:43:15 2020 +0200

    fix brand names

commit 7778482ef77d5bfd924b3d86ee97b5602ec42c63
Author: Muescha <184316+muescha@users.noreply.github.com>
Date:   Thu Apr 16 01:14:13 2020 +0200

    fix 404 link

commit 1a0791afd2e4f4b35c7645c3725002aa8ed0b0b7
Author: Muescha <184316+muescha@users.noreply.github.com>
Date:   Thu Apr 16 00:20:57 2020 +0200

    fix path to images

commit 5734a8c86736f2e670930f6e9c2bd71c10e77ced
Author: Muescha <184316+muescha@users.noreply.github.com>
Date:   Wed Apr 15 23:48:09 2020 +0200

    fix file name

commit 10ee6e3b46ed7bec566f0323ebb79a88247db6e5
Author: Muescha <184316+muescha@users.noreply.github.com>
Date:   Wed Apr 15 23:40:10 2020 +0200

    add links to TOC

commit 2983a4a1ee81e43c174fd0823b7487c769098d6d
Author: Muescha <184316+muescha@users.noreply.github.com>
Date:   Wed Apr 15 23:14:48 2020 +0200

    fix frontmatter

commit 22e43a0e01032a377b3e6347967db6d4f3b75460
Author: Muescha <184316+muescha@users.noreply.github.com>
Date:   Wed Apr 15 23:14:00 2020 +0200

fix frontmatter

commit fb08e2c9732d68dc1ce2cbf9a09159bf9229add5
Author: Muescha <184316+muescha@users.noreply.github.com>
Date:   Tue Apr 7 22:45:25 2020 +0200

fix brand name

commit 99d7c9f0c45eae63a9b8ed291cda26acac67acae
Author: Muescha <184316+muescha@users.noreply.github.com>
Date:   Tue Apr 7 21:29:20 2020 +0200

change bash to shell

commit 17dac01b7c640eb759d0788742323d9e38059aec (muescha/fix/tutorials-1-8-fix)
Author: Muescha <184316+muescha@users.noreply.github.com>
Date:   Thu Mar 12 14:42:07 2020 +0100

fix

commit 505e5268e81245ad3b8ce626100ef3fb02035455 (muescha/fix/anchor-tags-in-glossary)
Author: Muescha <184316+muescha@users.noreply.github.com>
Date:   Thu Feb 27 03:45:54 2020 +0100

fixes links

如果你这样做

git branch -avv

您将看到所有本地和远程分支以及它们所链接的上游分支。

-a--all用于列出远程和本地分支

-vv允许显示与远程分支的链接

为了查看您所有的本地提交,请使用:

git log origin/master..HEAD

为了查看来自所有分支的所有未推送的提交,请使用:

git log --branches --not --remotes

希望能帮助到你!

放心使用

git branch -avv这意味着:

-a:列出远程跟踪分支和本地分支。

-vv:用于详细或更详细的描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM