如何打开git auto-fetch? [英] How to turn on git auto-fetch?
问题描述
我有几个每天想要获取的git项目(例如早上)以及签出最后一次提交(如果没有本地更改,当然)到分支origin / dev(例如,它可能不会成为主分支)。那么如何为目录中的所有项目执行此操作?
如何为所有人执行此操作项目在目录中?一种方法是(在单独的本地目录中进行实验):
- 在该目录中创建本地回购库
- 将所有这些Git回购项目添加为子模块(git add submodule -b dev url / git / repo / for / a / project):它们将设置为每天跟踪开发分支
- (例如使用cron作业),执行
git子模块更新 - 递归--remote
:它将为每个子模块获取和检出来自/ dev的最新源代码。
请注意,目录中的本地回购作为这些子模块的父回购,并且完全是本地的:无需推回购回。它只是在那里受益于git 1.8.2+中引入的 子模块跟踪分支功能 (2013年3月)。
您的git项目回购可以完全忽略它们是父目录回购的子模块的事实。
命令,你可以触发fetch + checkout最后对 origin / dev
提交所有你的git项目回购。
I have several git projects which I want to fetch everyday (in the morning for example) and checkout to the last commit (if there are no local changes of course) to the branch "origin/dev" (e.g. it may not be a master branch). So how to do this for all projects in the directory?
How to do this for all projects in the directory?
One way would be to (experiment in a separate local directory):
- create a local repo in that directory
- add all those Git repos projects as submodules (git add submodule -b dev url/git/repo/for/a/project): they will be set to track the dev branch
- every day (with a cron job for instance), do a
git submodule update --recursive --remote
: that will fetch and checkout the latest from origin/dev for each submodules.
Note that the local repo in the directory act as a "parent repo" for those submodules, and is purely local: no need to push that repo. It is just there to benefit from the submodule tracking branch feature introduced in git 1.8.2+ (March 2013).
Your git project repos can ignore completely the fact they are submodules for the parent directory repo.
In one command, you trigger a fetch + checkout of the latest commits on origin/dev
for all your git project repos.
这篇关于如何打开git auto-fetch?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!