管理许多 git 存储库

发布于 2024-07-17 23:17:25 字数 310 浏览 10 评论 0原文

在 git 中设置项目很容易,因此即使对于小脚本,我也可以拥有单独的存储库。 现在的问题是如何管理它们。

我在多个地方使用这些存储库工作。 当我对某些存储库进行更改后,我希望能够更新其他位置的存储库。

所以我有一个目录,里面有很多存储库。

  1. 我怎样才能获取所有这些?
  2. 我如何检查其中是否有未提交的更改?
  3. 我如何检查其中是否有需要合并的更改?

如果能够用一个命令来完成这些工作那就太好了。

输出需要足够安静才能真正注意到要做的事情。

Setting up a project is easy in git and so I can have separate repository even for small script. Now the problem is how to manage them.

I work in multiple places with these repositories. When I have done changes to some repository, I want to be able to update the repositories in other places.

So I have a directory with many repositories in it.

  1. How can I fetch all of them?
  2. How can I check whether any of them have uncommitted changes?
  3. How can I check whether any of them have changes to merge?

And it would be nice to be able to do these with one command.

The output needs to be silent enough to actually notice the things to do.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(25

猛虎独行 2024-07-24 23:17:25

我强烈推荐多存储库工具 mr。 我曾经有一段时间按照别人推荐的方式使用自定义 shell 脚本,但是使用 mr 对我来说有以下好处:

  • 通用:可以使用各种版本控制系统的结合,而不仅仅是 git(例如 Mercurial、SVN 等) .)。
  • 速度很快:mr 可以并行执行多个作业。 我使用许多 git/mercurial 存储库,每天同步它们几次。 先生极大地加快了这一过程。
  • 管理存储库签出列表既简单又快捷。 只需使用“mr register”,而不是修改自定义脚本中的项目列表。

关于您有关静默输出的问题:可以使用命令行开关 -q 修改详细级别。 我更喜欢默认输出,它似乎很好地将输出统一为简短而清晰的摘要。

我对 mr 命令使用以下别名,以确保 mr 始终选择存储在 $HOME 中的默认项目列表,并使用 5 个并行线程:

alias mr='mr -d ~/ -j 5 '

I highly recommend the multiple repositories tool mr. I used to use a custom shell script as recommended by others for some time, but using mr has the following benefits for me:

  • It's generic: A conjunction of various version control systems can be used, not only git (e.g. Mercurial, SVN, etc.).
  • It's fast: mr can execute multiple jobs in parallel. I use a number of git/mercurial repositories and sync them several times a day. Mr tremendously speeds up this process.
  • It's easy and quick to manage the list of repository checkouts. Just use 'mr register' rather than modifying the list of projects in your custom script.

Regarding to your question about silent output: The level of verbosity can be modified using the command line switch -q. I prefer the default output which appears to nicely unify the output in a short and clear summary.

I use the following alias for the mr command to ensure that mr always picks up my default project list stored in $HOME, and uses 5 parallel threads:

alias mr='mr -d ~/ -j 5 '
晨与橙与城 2024-07-24 23:17:25

我必须说我从当前接受的答案开始(只是一堆迭代存储库的帮助器脚本),但总而言之,这对我来说是缺乏经验的。

因此,在尝试 mr、repo 和 git-submodules 后,我发现每个模块都以不同的方式存在缺陷,因此,我最终做了自己的变体: http://fabioz.github.io/mu-repo 这是一个成熟的工具——它的工作流程允许您:

  • 克隆多个存储库
  • 差异(并编辑)当前多个存储库中的更改
  • 预览传入的更改
  • 在多个存储库中并行运行命令
  • 创建存储库组
  • 在多个存储库上运行非 git 相关命令
  • 等(请参阅 主页了解更多信息)。

请注意,它支持任何运行 Python 的操作系统;)

I must say I started with the currently accepted answer (just a bunch of helpers scripts that iterate over the repositories), but all in all, it was a lacking experience for me.

So, after trying mr, repo and git-submodules, I found each lacking in a different way, so, I ended up doing my own variant: http://fabioz.github.io/mu-repo which is a mature tool at this point -- it has workflows which allow you to:

  • clone multiple repos
  • diff (and edit) current changes in multiple repos
  • preview incoming changes
  • run commands in multiple repos in parallel
  • create groups of repos
  • run non git-related commands over multiple repos
  • etc (see homepage for more info).

Note that it supports any OS where Python runs ;)

听风吹 2024-07-24 23:17:25

gr (git-run) 扩展 mr 的功能(仅适用于 git)。 我发现使用其标签系统组织多个 git 存储库更容易。 不过,gr 的代码维护得不好。 如果您使用的是 bash,请确保使用 -t 标记 而不是 #tag 形式。

gr (git-run) extends mr's functionality (only for git). I find it easier to organize multiple git repos using its tag system. The code for gr is not well maintained though. If you are using bash, make sure you use it with the -t tag instead of #tag form.

一刻暧昧 2024-07-24 23:17:25

我编写了一个名为 gita 的命令行工具来管理多个存储库。 它并排显示已注册存储库的状态,例如

在此处输入图像描述

它还可以从任何工作目录委托 git 命令/别名。

现在使用此工具回答您的问题:

如何获取所有这些?

gita fetch

如何检查其中是否有未提交的更改?

gita ll 命令在分支名称旁边显示 3 个可能的符号,表示

  • +:已暂存的更改
  • *:未暂存的更改
  • _< /code>:未跟踪的文件/文件夹

如何检查其中是否有需要合并的更改?

分支名称有 5 种颜色

  • :白色:本地分支没有远程分支
  • 绿色:本地分支与远程分支相同
  • 红色:本地分支与远程分支分歧
  • 紫色:本地分支领先于远程分支(适合推送)
  • 黄色:本地分支位于远程分支后面(适合合并)

要安装它,只需运行

pip3 install -U gita

I wrote a commandline tool called gita to manage multiple repos. It shows the status of registered repos side by side, for example

enter image description here

It can also delegate git commands/aliases from any working directory.

Now to answer your questions using this tool:

How can I fetch all of them?

gita fetch

How can I check whether any of them have uncommitted changes?

The gita ll command shows 3 possible symbols next to the branch name, which indicates

  • +: staged changes
  • *: unstaged changes
  • _: untracked files/folders

How can I check whether any of them have changes to merge?

The branch names are colored in 5 ways

  • white: local branch has no remote branch
  • green: local branch is the same as remote branch
  • red: local branch has diverged from remote branch
  • purple: local branch is ahead of remote branch (good for push)
  • yellow: local branch is behind remote branch (good for merge)

To install it, simply run

pip3 install -U gita
孤者何惧 2024-07-24 23:17:25

我编写了一个名为“RepoZ”的工具,只要您克隆 git 存储库或更改其中的任何内容,它就会自动发现它们例如,他们喜欢切换分支。

一旦找到,存储库就会被“跟踪”。 这将简单地将它们显示在本地存储库列表中,包括受 posh-git 启发的密集状态信息。 这包含当前分支以及其他内容,例如文件编辑以及传入或传出提交的计数。

RepoZ UI

这有助于跟踪本地存储库以及要提交或推送的未完成工作。 此外,您还可以使用存储库列表作为导航,从一个存储库切换到另一个存储库。

RepoZ 导航

“我怎样才能获取所有这些?”

Windows 版本提供了一个上下文菜单来获取或拉取存储库。 通过多选,您可以同时对多个存储库运行操作。

但是,您可能会发现另一个功能非常有用:

RepoZ Auto-Fetch

通过自动获取,您可以告诉 RepoZ 在后台定期获取所有 git 存储库的遥控器。 当然,这些获取不会与您的本地提交发生冲突。 没有像 git pull 那样的本地合并尝试。

I wrote a tool called "RepoZ" which automatically discovers git repositories as soon as you clone them or change anything in them like switching a branch, for example.

Once found, the repositories are "tracked". That will simply show them in a list of local repositories including a dense status information inspired by posh-git. This contains the current branch and further stuff like file edits and the count of incoming or outgoing commits.

RepoZ UI

This helps to keep track of your local repositories and unfinished work to commit or push. In addition, you can use the repository list as navigation to switch from one repository to another.

RepoZ Navigation

"How can I fetch all of them?"

The version for Windows offers a context menu to fetch or pull a repository. With multi-select you can run actions on multiple repositories at once.

However, you might find another feature very useful:

RepoZ Auto-Fetch

With Auto fetch, you can tell RepoZ to fetch the remotes of all your git repositories periodically in the background. These fetches won't collide with your local commits, of course. There are no local merge attempts like with git pull.

分开我的手 2024-07-24 23:17:25

您可以尝试将 repo 与自定义 manifest.xml 文件结合使用指定您的存储库所在的位置。 关于如何执行此操作,有更多文档

它是Android AOSP 项目的标准。

或者,您可以使用 git-submodule(1)

You could try using repo with a custom manifest.xml file to specify where your repositories are. There is some more documentation on how to do this.

It's the standard for Android AOSP project.

Alternatively you could use git-submodule(1).

落花浅忆 2024-07-24 23:17:25

我创建了一个别名和一个函数来在目录中可用的所有存储库上运行任何 git 命令(递归地)。 您可以在这里找到它: https://github.com/jaguililla/dotfiles/git

这是代码:

#!/bin/sh
# To use it: source git_aliases

# Example: rgita remote \;
alias rgita='find . -type d -name .git -execdir git'

# Example: rgit remote -vv
rgit() {
  rgita "$@" \;
}

希望有帮助:)

I've made an alias and a function to run any git command on all repositories available in a directory (recursively). You can find it here: https://github.com/jaguililla/dotfiles/git

This is the code:

#!/bin/sh
# To use it: source git_aliases

# Example: rgita remote \;
alias rgita='find . -type d -name .git -execdir git'

# Example: rgit remote -vv
rgit() {
  rgita "$@" \;
}

Hope it helps :)

一直在等你来 2024-07-24 23:17:25

我使用此脚本轻松地在我的所有存储库中执行 git 命令。

#!/bin/sh
if [ ! "$1" = "" ] ; then

   if [ "$GITREPO" = "" -a -d "$HOME/cm/src" ] ; then
      GITREPO="$HOME/cm/src"
   fi

   if [ "$GITREPO" != "" ] ; then

      echo "Git repositories found in $GITREPO"
      echo "-=-=-=-=-=-=-=-=-=-=-=-=-=-"

      DIRS="`/bin/ls -1 $GITREPO`"

      for dir in $DIRS ; do

         if [ -d $GITREPO/$dir/.git ] ; then
            echo "$dir -> git $1"
            cd $GITREPO/$dir ; git $@
            echo
         fi

      done
   else

      echo "Git repositories not found."

   fi
fi

默认情况下,脚本将在 ~/cm/src 中查找 git 存储库,但您可以通过根据自己的喜好设置 GITREPO 环境变量来覆盖它。

此脚本基于此脚本

I use this script to easily execute git commands in all of my repositories.

#!/bin/sh
if [ ! "$1" = "" ] ; then

   if [ "$GITREPO" = "" -a -d "$HOME/cm/src" ] ; then
      GITREPO="$HOME/cm/src"
   fi

   if [ "$GITREPO" != "" ] ; then

      echo "Git repositories found in $GITREPO"
      echo "-=-=-=-=-=-=-=-=-=-=-=-=-=-"

      DIRS="`/bin/ls -1 $GITREPO`"

      for dir in $DIRS ; do

         if [ -d $GITREPO/$dir/.git ] ; then
            echo "$dir -> git $1"
            cd $GITREPO/$dir ; git $@
            echo
         fi

      done
   else

      echo "Git repositories not found."

   fi
fi

By default the script will look for git repositories in ~/cm/src but you can override this by setting the GITREPO environment variable to your liking.

This script is based on this script.

浪推晚风 2024-07-24 23:17:25

gitslave 是一个工具,它可以通过在超级项目和子项目之间创建超级项目/子项目关系来在多个存储库上运行相同的命令潜艇。 这(默认情况下)提供输出摘要,以便您可以专注于提供唯一输出的存储库(对于 git status 有用,对于 git ls-files 不太有用)。

这通常用于需要将多个存储库组装在一起并同时将它们保存在同一分支或标签上的项目。 对于我的(裸)存储库目录,我只有一个小 makefile,它可以让我运行任意 git 命令,如您所见,我主要用于 fsck 和 gc:

full: fsck-full gc-aggressive
        @:

fsck-full:
        for f in */.; do (cd $f; echo $f; git fsck --full || echo $f FAILED); done

gc-aggressive:
        for f in */.; do (cd $f; echo $f; git gc --aggressive || echo $f FAILED); done

%:
        for f in */.; do (cd $f; git $@ || echo $f FAILED); done

gitslave is a tool which can run the same command over many repositories by creating a superproject/subproject relationship between the super and the subs. This (by default) provides output summarization so you can concentrate on the repositories which provide unique output (useful for git status, not so useful for git ls-files).

This is typically used for projects where you need to assemble several repositories together and keep them on the same branch or tag at the same time or whatever. For my directory of (bare) repositories I just have a little makefile which lets me run arbitrary git commands, which as you see I primarily use for fsck and gc:

full: fsck-full gc-aggressive
        @:

fsck-full:
        for f in */.; do (cd $f; echo $f; git fsck --full || echo $f FAILED); done

gc-aggressive:
        for f in */.; do (cd $f; echo $f; git gc --aggressive || echo $f FAILED); done

%:
        for f in */.; do (cd $f; git $@ || echo $f FAILED); done
一瞬间的火花 2024-07-24 23:17:25

您可以使用 git-status-all gem 来实现此目的:https:// /github.com/reednj/git-status-all

# install the gem    
gem install git-status-all

# use the status-all subcommand to scan the directory
git status-all

还有一个获取选项,可以在显示状​​态之前从源获取所有存储库:

git status-all --fetch

git status all

You can use the git-status-all gem for this: https://github.com/reednj/git-status-all

# install the gem    
gem install git-status-all

# use the status-all subcommand to scan the directory
git status-all

There is also a fetch option that will fetch from origin for all the repositories before displaying the status:

git status-all --fetch

git status all

纸短情长 2024-07-24 23:17:25

为此,您可以使用 every,它可以按照此模式在多个目录中运行 cli 命令 every

安装:
npm i -g every-cli

使用示例: 每个 git 分支

- repo-1
  master
- repo-2
  develop

For this purpose, you can use every which can run cli commands in multiple directories following this pattern every <command>

Install:
npm i -g every-cli

Usage example: every git branch

- repo-1
  master
- repo-2
  develop
找回味觉 2024-07-24 23:17:25

如果有人仍在查看此线程,请查看我的名为 gitme 的 shell 脚本,

您将需要手动输入本地 git 存储库,但我每天都使用此工具在多台计算机上协作多个 git 项目。

你可以运行 git clone https://github.com/robbenz/gitme.git

脚本也发布在下面

#!/bin/bash -e

REPOS=( 
/Users/you/gitrepo1
/Users/you/gitrepo2
/Users/you/gitrepo3
/Users/you/gitrepo4
)

MOVE="Moving to next REPO... \n" 

tput setaf 2;echo "What ya wanna do? You can say push, pull, commit, ftp push, or status"; tput sgr0

read input

if [ $input =  "commit" ]
then
    tput setaf 2;echo "Do you want a unique commit message? [y/n]";tput sgr0
    read ans
    if [ $ans = "y" ]
    then 
        for i in "${REPOS[@]}"
        do
            cd "$i"
            tput setaf 6;pwd;tput sgr0 
            git add . -A
            read -p "Commit description: " desc  
            git commit -m "$desc"
            tput setaf 2;echo  $MOVE;tput sgr0 
            sleep 1
        done 
    else 
        for i in "${REPOS[@]}"
        do
            cd "$i"
            tput setaf 6;pwd;tput sgr0 
            git add . -A
            git commit -m "autocommit backup point"
            tput setaf 2;echo  $MOVE;tput sgr0 
            sleep 1
        done
    fi 
elif [ $input = "push" ] || [ $input = "pull" ] || [ $input = "ftp push" ] || [ $input = "status" ]
    then
        for i in "${REPOS[@]}"
do
    cd "$i"
    tput setaf 6;pwd;tput sgr0 
    git $input 
    tput setaf 2;echo  $MOVE;tput sgr0 
    sleep 1
    done 
else tput setaf 1;echo "You have zero friends";tput sgr0 
fi

我在我的 ~/.bash_profile 中设置了一个别名所以 alias gitme='sh /path/to/gitme.sh'

If anyone is still looking at this thread please checkout my shell script called gitme

you will need to manually input your local git repos but i use this tool everyday to collaborate multiple git projects on multiple computers.

you can run git clone https://github.com/robbenz/gitme.git

also the script is posted below

#!/bin/bash -e

REPOS=( 
/Users/you/gitrepo1
/Users/you/gitrepo2
/Users/you/gitrepo3
/Users/you/gitrepo4
)

MOVE="Moving to next REPO... \n" 

tput setaf 2;echo "What ya wanna do? You can say push, pull, commit, ftp push, or status"; tput sgr0

read input

if [ $input =  "commit" ]
then
    tput setaf 2;echo "Do you want a unique commit message? [y/n]";tput sgr0
    read ans
    if [ $ans = "y" ]
    then 
        for i in "${REPOS[@]}"
        do
            cd "$i"
            tput setaf 6;pwd;tput sgr0 
            git add . -A
            read -p "Commit description: " desc  
            git commit -m "$desc"
            tput setaf 2;echo  $MOVE;tput sgr0 
            sleep 1
        done 
    else 
        for i in "${REPOS[@]}"
        do
            cd "$i"
            tput setaf 6;pwd;tput sgr0 
            git add . -A
            git commit -m "autocommit backup point"
            tput setaf 2;echo  $MOVE;tput sgr0 
            sleep 1
        done
    fi 
elif [ $input = "push" ] || [ $input = "pull" ] || [ $input = "ftp push" ] || [ $input = "status" ]
    then
        for i in "${REPOS[@]}"
do
    cd "$i"
    tput setaf 6;pwd;tput sgr0 
    git $input 
    tput setaf 2;echo  $MOVE;tput sgr0 
    sleep 1
    done 
else tput setaf 1;echo "You have zero friends";tput sgr0 
fi

I setup an alias in my ~/.bash_profile so alias gitme='sh /path/to/gitme.sh'

清晰传感 2024-07-24 23:17:25

我为此编写了一个 CLI 工具,请参阅 https://manicli.com/。 它还具有一些不错的附加功能:

  • 在多个存储库上运行命令
  • 声明式
  • 配置 灵活的过滤,选择 1 个项目、具有标签或子路径的项目

I wrote a CLI tool for this, see https://manicli.com/. It also has some nice additional features:

  • Run commands over many repos
  • Declarative configuration
  • Flexible filtering, select 1 project, projects having a tag, or a subpath
捂风挽笑 2024-07-24 23:17:25

我找到了一个很好的解决方案,可以从具有 .git 文件夹的所有子目录中提取当前分支,即使每个存储库签出了不同的分支。
该命令是一个单行命令,足够灵活,可以针对不同的 git 命令进行修改,并且可以使用别名。

只需复制并粘贴以下内容:

find . -type d -maxdepth 2 -name .git -exec sh -c 'cd "$0" && cd .. && git pull origin $(git rev-parse --abbrev-ref HEAD)' {} \;

分解:

find . -type d -maxdepth 2 -name .git 

在当前目录 (find .) 中查找所有名为“.git”的目录 (-type d) (-name .git),最多查找两个目录深度 ( 2 而不是 1,因为我们正在 git repo 文件夹中查找 git 文件夹)。

-exec sh -c 

运行以下 shell 命令 (exec sh -c)

'cd "$0" && cd .. && git pull origin $(git rev-parse --abbrev-ref HEAD)'

将目录更改为第一个参数 (cd "$0"),然后将目录向上更改一级以离开 .git 文件夹 (cd ..),然后在指定分支时执行 git pull origin通过运行 git rev-parse... 来获取当前分支的 HEAD 提交。

{} \;

“{}”是我们从初始 find 命令获得的结果相对路径。 这 ; 用于结束命令。

在 MacOS 10.14.6 上的 zsh 上进行了测试。 按原样,仅当远程和本地分支命名相同时才有效,据我所知。

您可以修改它来获取状态。 我希望您可以添加参数以进一步使其更加灵活,但我还没有尝试过。

I've found a great solution for pulling from the current branch from all sub-directories that have a .git folder, even if each repo has a different branch checked out.
The command is a one-liner, flexible enough to modify for different git commands, and can be aliased.

Just copy and paste the following:

find . -type d -maxdepth 2 -name .git -exec sh -c 'cd "$0" && cd .. && git pull origin $(git rev-parse --abbrev-ref HEAD)' {} \;

Breaking it down:

find . -type d -maxdepth 2 -name .git 

Find all directories (-type d) in the current directory (find .) that have the name ".git" (-name .git), looking a maximum of two directories deep (2 rather than 1 because we're looking for the git folder within the git repo folder).

-exec sh -c 

Run the following shell command (exec sh -c)

'cd "$0" && cd .. && git pull origin $(git rev-parse --abbrev-ref HEAD)'

Change directory to the first argument (cd "$0"), then change directory one level up to leave the .git folder (cd ..) then do git pull origin while specifying the branch by running git rev-parse... for the current branch's HEAD commit.

{} \;

The "{}" is the result relative path we get from the initial find command. The ; is used to end the command.

Tested on MacOS 10.14.6 on zsh. As-is, works only when remote and local branches are named the same, AFAIK.

You can modify this to get status. I expect you might be able to add arguments to further make this more flexible but I haven't tried yet.

三人与歌 2024-07-24 23:17:25

您应该查看 CPAN 上的 rgit,它在目录树中的所有存储库上递归执行 git 命令。

来自文档:

该实用程序递归地搜索
根目录(可能是
当前工作目录或 - 如果是
已设置 - 给出的目录
GIT_DIR 环境变量)
所有 git 存储库,对此列表进行排序
通过存储库路径,chdir 进入
他们每个人,并执行
指定的 git 命令。

You should check out rgit on the CPAN which recursively executes git commands on all repositories in a directory tree.

From the docs:

This utility recursively searches in a
root directory (which may be the
current working directory or - if it
has been set - the directory given by
the GIT_DIR environment variable) for
all git repositories, sort this list
by the repository path, chdir into
each of them, and executes the
specified git command.

北陌 2024-07-24 23:17:25

我刚刚创建了一个可以实现您想要的功能的工具!

  1. 我怎样才能获取所有这些? gmaster fetch
  2. 如何检查其中是否有未提交的更改? gmaster status
  3. 我如何检查其中是否有需要合并的更改? gmaster status

它被称为 gitmaster:https://github.com/francoiscabrol/gitmaster

I have just created a tool that do what you want!

  1. How can I fetch all of them? gmaster fetch
  2. How can I check whether any of them have uncommitted changes? gmaster status
  3. How can I check whether any of them have changes to merge? gmaster status

It is called gitmaster: https://github.com/francoiscabrol/gitmaster

欢你一世 2024-07-24 23:17:25

我将这个简单的 bash 函数写入我的 .bash_profile 中,以便能够仅在所有 git 存储库中运行 git、maven、gradle 或任何其他 bash 命令:

# usefull function to work with multiple git repositories
all() {
    failed=0
    printf '>>> START RUNNING: "%s" >>>' "$*"
    for d in */; do
        pushd "$d" > /dev/null
        if [ -d ".git" ]
        then
            printf '\n--------------------------------------------\n\n'
            pwd
            eval $@
            if [ $? -ne 0 ]
            then
                failed=1
                break;
            fi
        fi
        popd > /dev/null
    done
    if [ $failed -eq 0 ]
    then
        printf '\n--------------------------------------------\n'
        printf '<<< RAN "%s" WITH SUCCESS!!! <<<' "$*"
    else
        printf '\n<<< FAILED!!! <<<'
    fi
}

这可以这样使用

all git st
all git pull
all ./gradlew clean test
etc.

I wrote this simple bash function into my .bash_profile to be able to run git, maven, gradle, or any other bash command in all git repositories only:

# usefull function to work with multiple git repositories
all() {
    failed=0
    printf '>>> START RUNNING: "%s" >>>' "$*"
    for d in */; do
        pushd "$d" > /dev/null
        if [ -d ".git" ]
        then
            printf '\n--------------------------------------------\n\n'
            pwd
            eval $@
            if [ $? -ne 0 ]
            then
                failed=1
                break;
            fi
        fi
        popd > /dev/null
    done
    if [ $failed -eq 0 ]
    then
        printf '\n--------------------------------------------\n'
        printf '<<< RAN "%s" WITH SUCCESS!!! <<<' "$*"
    else
        printf '\n<<< FAILED!!! <<<'
    fi
}

This can be used this way

all git st
all git pull
all ./gradlew clean test
etc.
深空失忆 2024-07-24 23:17:25

免责声明:我正在 www.repoflow.com 上开发此工具

我怎样才能获取所有这些?
我如何检查其中是否有需要合并的更改?

  • 您可以获取所有涉及的存储库(或推/拉/提交它们),获取后,UI 将使用新的存储库状态进行更新,如果存储库出现分歧,您可以看到冲突类型并开始合并它们。

输入图片此处描述

如何检查其中是否有未提交的更改?

  • 在 UI 上,您可以查看每个存储库的文件状态(您可以单独或批量添加/删除它们)。

输入图像这里的描述

我正在研究这个,但这也是解决OP问题并帮助管理多个存储库,您可以使用UI或底层GraphQL API来创建您自己的脚本,请将其视为另外一个选择。

Disclaimer: I am working on this tool at www.repoflow.com

How can I fetch all of them?
How can I check whether any of them have changes to merge?

  • You can fetch all the involved repositories (or push/pull/commit them), after the fetch the UI will be updated with the new repository state, if the repository is diverged you can see the kind of conflicts and begin merge them.

enter image description here

How can I check whether any of them have uncommitted changes?

  • On the UI you can see the state of the files for each repository (You can add/remove them individually or in bulk).

enter image description here

I am working on this, but this is also solving the OP questions and help manage multiple repositories in general, you can use the UI or the underlying GraphQL API to create your own scripts, please consider it as another option.

蘑菇王子 2024-07-24 23:17:25

有一个方便的工具可以获取所有多个存储库。
git-pull-all 是一个命令行工具,可以在多个 git 存储库上异步执行。

安装

npm install -g git-pull-all

用法

假设您有以下文件和目录:

~/Projects/
  cool-examples/
    .git/
  funny-movies/
  my-todos.txt
  super-express/
    .git/

当您在 ~/Projects 目录上运行 git-pull-all 命令时,它应该找到子 git 存储库(在上述情况下) cool-examplessuper-express),然后对它们分别执行 git pull

$ cd ~/Projects
$ git-pull-all
funny-movies/
Not a git repository
cool-examples/
Already up-to-date.
super-express/
Already up-to-date.
Done!
git-pull-all ~/Projects

GitHub 链接: https://github.com/tatsuyaoiw/git-pull-all

There's a handy tool to fetch all multiple repositories.
git-pull-all is a command line tool to execute on multiple git repositories in asynchronously.

Installation

npm install -g git-pull-all

Usage

Assume you have these files and directories:

~/Projects/
  cool-examples/
    .git/
  funny-movies/
  my-todos.txt
  super-express/
    .git/

When you run git-pull-all command on ~/Projects directory, it should find child git repositories (in the above case cool-examples and super-express) then execute git pull on each of them.

$ cd ~/Projects
$ git-pull-all
funny-movies/
Not a git repository
cool-examples/
Already up-to-date.
super-express/
Already up-to-date.
Done!
git-pull-all ~/Projects

GitHub link: https://github.com/tatsuyaoiw/git-pull-all

动听の歌 2024-07-24 23:17:25

我使用 Visual Studio 代码。 我们的代码库中有大约 20 个库,它们都是单独的 Git 存储库,Visual Studio Code 中的源代码控制选项卡非常适合“一目了然”地了解本地存储库落后或领先的程度。 还有一些设置可以定期获取以保持该信息最新,以及刷新按钮。

它不像脚本那么方便,但是当涉及到我的源代码控制时,我喜欢成为那个进行更改的人。 需要编写非常好的脚本才能小心,不要覆盖更改等。使用 VS Code 方法,您可以快速获得大量信息,以便自己采取行动。

下面是它的屏幕截图:

VS Code 中的源代码控制窗口

I use Visual Studio code. We have around 20 libraries in our codebase that are all separate Git repos, and the source control tab in Visual Studio Code is pretty good for seeing an "at a glance" view of how far behind or ahead local repos are. There are also settings to periodically fetch to keep that info up to date, as well as a refresh button.

Its not as convenient as a script, but when it comes to source control for me I like to be the one making changes. It takes a very well-written script to be careful to not overwrite changes, etc. With the VS Code approach, you get a good amount of info quickly that you can act on yourself.

Here is a screenshot of what it looks like:

Source control window in VS Code

此岸叶落 2024-07-24 23:17:25

扩展 https://stackoverflow.com/a/816674/1869000 (现在可以在 GitHub 上获取存储库)

我建议您检查此工具https://github.com/googleapis/github-repo-automation Google 使用它来管理多个存储库。

关于您关于奉献变更的问题,变更应该是 PR,以便您可以对其做出反应。

https://github.com/tj/git-extras 可以帮助您编写脚本你的场景。

  1. 我怎样才能获取所有这些?
    Google 解决方案上的repo 同步< /p>

  2. < p>如何检查其中是否有未提交的更改?
    您可以使用 lib 功能轻松编写逻辑

  3. 如何检查其中是否有需要合并的更改?
    PR 应该是分支需要合并的最终指示,但如果你有其他逻辑 - 上面

检查 git extras 命令的想法请参阅 https://github.com/tj/git-extras/blob/master/Commands.md#git-show-unmerged-branches< /a>

Expanding on https://stackoverflow.com/a/816674/1869000 (Now repo is available on GitHub)

I suggest you check this tool https://github.com/googleapis/github-repo-automation used by Google to manage multiple repos.

About your question about dedicating changes, changes should be PRs so you can react to them.

https://github.com/tj/git-extras could help you write a script for your scenarios.

  1. How can I fetch all of them?
    repo sync on the google solution

  2. How can I check whether any of them have uncommitted changes?
    You can easily write your logic using the lib feature

  3. How can I check whether any of them have changes to merge?
    PR should be the ultimate indication that branches need to merge, but if you have another logic - the above

check git extras commands for ideas see https://github.com/tj/git-extras/blob/master/Commands.md#git-show-unmerged-branches

想挽留 2024-07-24 23:17:25

请尝试 gitas

gitas 状态

gitas status 标志:

  -t, --time           time of last commit shown (default true)
  -f, --format {r|i}   format time: relative|iso (default r)
  -b, --branch         branch shown
  -q, --query          query fetch needed (implies -br)
  -r, --remote         remote shown
  -l, --url            url shown
  -d, --dirty          dirty shown (default true)
  -u, --untracked      untracked shown
  -s, --stash          stash shown
  -o, --order {t|n}    order: time|name (default t)
  -e, --emit {t|j|m}   emit format: table|json|markdown (default t)
  -h, --help           help for status

Please try gitas.

gitas status

gitas status flags:

  -t, --time           time of last commit shown (default true)
  -f, --format {r|i}   format time: relative|iso (default r)
  -b, --branch         branch shown
  -q, --query          query fetch needed (implies -br)
  -r, --remote         remote shown
  -l, --url            url shown
  -d, --dirty          dirty shown (default true)
  -u, --untracked      untracked shown
  -s, --stash          stash shown
  -o, --order {t|n}    order: time|name (default t)
  -e, --emit {t|j|m}   emit format: table|json|markdown (default t)
  -h, --help           help for status
冷…雨湿花 2024-07-24 23:17:25

我使用代码编辑器(VS code)的多光标选择/多行编辑功能来创建批处理/shell 脚本并一次性执行它。 通过这个简单愚蠢的解决方案,我知道我在做什么以及执行这些命令可以期望什么。 无需猜测,无需学习,无需定制。 另一个原因是,每次我想在驻留在公共父目录中的不同存储库上执行命令时。

I use multi-cursor-select/multi-line editing feature of my code editor (VS code) to create batch/shell script and execute it in one go. With this simple stupid solution, I know what I'm doing and what I can expect from execution of those commands. No guessing, no learning, no customisation needed. Another reason is, every time I want to execute commands on different set of repos which reside in a common parent directory.

千里故人稀 2024-07-24 23:17:25

请按照下面提到的步骤从所有存储库中提取代码:

  1. 使用扩展名 .bat 创建一个新文件,
  2. 将该文件放置在所有存储库文件夹所在的同一层次结构中
  3. 编辑 .bat 文件并添加下面提到的脚本
FOR /D %%G in (%cd%\*) Do cd %%G & call git branch & call git pull & cd ..
echo All code pulled successfully!!
pause
  1. 保存文件并双击开始提取代码

Please follow below-mentioned steps to pull code from all the repositories:

  1. create a new file using extension as .bat
  2. place that file in the same hierarchy where you have all your repository folders
  3. edit .bat file and add below-mentioned script
FOR /D %%G in (%cd%\*) Do cd %%G & call git branch & call git pull & cd ..
echo All code pulled successfully!!
pause
  1. save the file and double click to start pulling your code
玩套路吗 2024-07-24 23:17:25

https://github.com/wwjamieson3/envisionTools 有一个名为 gitstat 的 bash 脚本,可以完成此操作以及整个操作更多。 它与 GNU 和 Mac 兼容。 如果需要,它可以从远程执行获取。 它显示未跟踪、修改、添加、删除和暂存的文件。 它与远程的不同之处在于显示远程上未合并的提交和未推送的本地提交。 它还可以以摘要或详细模式甚至 HTML 显示颜色编码结果。 它使用locate而不是find,因为它速度无限快,甚至会提示更新您的locate数据库(如果它太旧)。

https://github.com/wwjamieson3/envisionTools has a bash script called gitstat that does this and a whole lot more. It's GNU and mac compatible. It can perform fetches from remotes if asked. It shows untracked, modified, added, deleted and staged files. It differences with remotes by showing unmerged commits on remotes and unpushed local commits. It also can display color coded results in summary or detailed mode and even HTML. It uses locate instead of find because it's infinitely faster and will even prompt to update your locate database if it's getting too old.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文