repo 同步命令的替代方案是什么?

tus*_*cmc 4 git android-manifest repo

我是 git 新手,我想在执行后手动执行清单文件repo init,而不是执行repo sync。测量正常git命令和repo sync不同情况下的时间差。但我不确定 repo 使用哪个 git 命令。

我知道这repo只是大型代码库的 git 包装器。

我只想知道git clone如果我有以下变量,确切的命令是什么。

- 名称 - 路径 - 修订版 - 上游 - 远程

我知道如何形成 git clone 的 url,但不确定修订版和上游。

Sau*_*ari 5

这是一个示例清单default.xml

\n
<manifest>\n        <remote  name="aosp"\n               fetch="https://android.googlesource.com/"/>\n        <remote  name="test"\n               fetch="https://github.com/test/"/>\n        <default revision="master"\n               remote="test"\n               sync-j="4" />\n        <project name="platform/tools/motodev" path="tools/motodev" revision="69989786cefbde82527960a1e100ec9afba46a98" upstream="master" remote="aosp"/>\n</manifest>\n
Run Code Online (Sandbox Code Playgroud)\n

创建父目录用于测试

\n
mkdir repotest\ncd repotest\n
Run Code Online (Sandbox Code Playgroud)\n

为清单创建 git 存储库

\n
mkdir local_manifest\ncd local_manifest\ngit init\n# Create the default.xml file\ngit add default.xml\ngit commit -m "Local Manifest"\ncd ..\n
Run Code Online (Sandbox Code Playgroud)\n

下载工具repo

\n
mkdir -p .bin\nPATH="${HOME}/repotest/.bin:${PATH}"\ncurl https://storage.googleapis.com/git-repo-downloads/repo > .bin/repo\nchmod a+rx .bin/repo\n
Run Code Online (Sandbox Code Playgroud)\n

根据本地清单进行初始化

\n
mkdir test\ncd test\nrepo init -u ~/repotest/local_manifest/\n
Run Code Online (Sandbox Code Playgroud)\n

修改 的源代码repo以获得更多调试输出(除了--traceGIT_TRACE=1

\n
nano .repo/repo/git_command.py\n# Remove stderr argument from the subprocess.Popen call (line no: ~292)\n# Also comment the line at line no: ~331 which includes the use of the above removed argument stderr\n# Save the file and exit\n
Run Code Online (Sandbox Code Playgroud)\n

同步

\n
export GIT_TRACE=1\nrepo --trace sync &> ../log\ncd ..\n
Run Code Online (Sandbox Code Playgroud)\n

过滤日志

\n
grep "built-in:\\|curl\\|export" < log > temp\nawk -F \'[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]+ git.c:\' \'{print $1}\' > trim1 < temp\nawk -F \'trace: built-in:\' \'{print $2}\' > trim2 < temp\npaste -d\' \' trim1 trim2 > filtered_log\n
Run Code Online (Sandbox Code Playgroud)\n

过滤日志显示正在执行的 git 命令的顺序

\n
  git version\n  git describe HEAD\n  git config --file /home/test/repotest/test/.repo/manifests.git/config --null --list\n  git config --file /home/test/repotest/test/.repo/repo/.git/config --null --list\n: export GIT_DIR=/home/test/repotest/test/.repo/manifests.git \n  git fetch origin --tags \'+refs/tags/*:refs/tags/*\' \'+refs/heads/*:refs/remotes/origin/*\' +refs/heads/master:refs/remotes/origin/master\n  git upload-pack /home/test/repotest/local_manifest/\n  git rev-list --objects --stdin --not --all --quiet --alternate-refs\n  git gc --auto\n  git symbolic-ref -m \'manifest set to refs/heads/master\' refs/remotes/m/master refs/remotes/origin/master\n: export GIT_DIR=/home/test/repotest/test/.repo/project-objects/platform/tools/motodev.git \n  git init\n  git config --file /home/test/repotest/test/.repo/projects/tools/motodev.git/config --null --list\n  git config --file /home/test/repotest/test/.repo/projects/tools/motodev.git/config --replace-all filter.lfs.smudge \'git-lfs smudge --skip -- %f\'\n  git config --file /home/test/repotest/test/.repo/projects/tools/motodev.git/config --replace-all filter.lfs.process \'git-lfs filter-process --skip\'\n  git config --file /home/test/repotest/test/.repo/projects/tools/motodev.git/config --unset-all core.bare\n  git config --file /home/test/repotest/test/.repo/projects/tools/motodev.git/config --replace-all remote.aosp.url https://android.googlesource.com/platform/tools/motodev\n  git config --file /home/test/repotest/test/.repo/projects/tools/motodev.git/config --replace-all remote.aosp.projectname platform/tools/motodev\n  git config --file /home/test/repotest/test/.repo/projects/tools/motodev.git/config --replace-all remote.aosp.fetch \'+refs/heads/*:refs/remotes/aosp/*\'\ncurl --fail --output /home/test/repotest/test/.repo/projects/tools/motodev.git/clone.bundle.tmp --netrc --location https://android.googlesource.com/platform/tools/motodev/clone.bundle \n: export GIT_DIR=/home/test/repotest/test/.repo/projects/tools/motodev.git \n  git fetch /home/test/repotest/test/.repo/projects/tools/motodev.git/clone.bundle \'+refs/heads/*:refs/remotes/aosp/*\' \'+refs/tags/*:refs/tags/*\'\n  git index-pack --fix-thin --stdin\n  git rev-list --objects --stdin --not --all --quiet --alternate-refs\n  git gc --auto\n  git fetch aosp --tags \'+refs/tags/*:refs/tags/*\' \'+refs/heads/*:refs/remotes/aosp/*\' +refs/heads/master:refs/remotes/aosp/master\n  git fetch-pack --stateless-rpc --stdin --lock-pack --thin --no-progress https://android.googlesource.com/platform/tools/motodev/\n  git unpack-objects -q --pack_header=2,2\n  git rev-list --objects --stdin --not --all --quiet --alternate-refs\n  git gc --auto\n  git update-ref -m \'manifest set to 69989786cefbde82527960a1e100ec9afba46a98\' --no-deref refs/remotes/m/master 69989786cefbde82527960a1e100ec9afba46a98^0\n  git gc --auto\n  git read-tree --reset -u -v HEAD\n
Run Code Online (Sandbox Code Playgroud)\n

现在有很多命令。(观察:repo使用curl 下载存储库)。

\n

正如用户ElpieKay所建议的,对于上述清单文件,git 命令的近似值为:

\n
git clone https://android.googlesource.com/platform/tools/motodev -b master -- tools/motodev \ncd tools/motodev\ngit checkout 69989786cefbde82527960a1e100ec9afba46a98\n
Run Code Online (Sandbox Code Playgroud)\n

要比较该工具和 git 的性能repo,您可以执行以下操作:

\n
# For repo tool\nrepo --time sync\n
Run Code Online (Sandbox Code Playgroud)\n
# For git commands\nexport GIT_TRACE_PERFORMANCE=1\ngit clone $remote -b $upstream -- $path \ncd $path \ngit checkout $revision\n
Run Code Online (Sandbox Code Playgroud)\n

或使用time命令获取 git 命令的总执行时间

\n
time -p sh -c \'git clone $remote -b $upstream -- $path ; cd $path ; git checkout $revision\'\n
Run Code Online (Sandbox Code Playgroud)\n
\n

注意: remote有一个属性fetch,其值为服务器的url前缀。前缀和名称构成远程存储库的实际 url - 用户ElpieKay

\n
\n

有关 git 中使用的调试变量的更多信息:

\n
\n

GIT_TRACE_PERFORMANCE

\n

控制性能数据的记录。输出\n显示每个特定 git 调用需要多长时间。

\n

git_trace

\n

控制一般跟踪,\xe2\x80\x99 不适合任何特定类别。\n这包括别名的扩展以及对其他\n子程序的委托。

\n
\n