私信  •  关注

Chetabahana

Chetabahana 最近创建的主题
Chetabahana 最近回复了
4 年前
回复了 Chetabahana 创建的主题 » Github:这个分支是X提交的[duplicate]

保持一个分叉的存储库总是永久更新有两件主要的事情。

从叉子主人那里 .

所以当你 接受后,您可以安全地删除分支,因为当您使用上游更新分支时,您贡献的代码将位于分叉存储库的主控中。通过这个你的主人将永远在干净的条件下创建一个新的分支做另一个改变。

2。创建计划作业 让叉子主人 自动更新 .

cron . 这里是一个例子代码,如果你在linux中做的话。

$ crontab -e

把这个密码写在 crontab file 按小时执行工作。

0 * * * * sh ~/cron.sh

cron.sh 脚本文件和 git interaction 具有 ssh-agent expect 如下所示

#!/bin/sh
WORKDIR=/path/to/your/dir   
REPOSITORY=<name of your repo>
MASTER="git@github.com:<username>/$REPOSITORY.git"   
UPSTREAM=git@github.com:<upstream>/<name of the repo>.git  

cd $WORKDIR && rm -rf $REPOSITORY
eval `ssh-agent` && expect ~/.ssh/agent && ssh-add -l
git clone $MASTER && cd $REPOSITORY && git checkout master
git remote add upstream $UPSTREAM && git fetch --prune upstream
if [ `git rev-list HEAD...upstream/master --count` -eq 0 ]
then
    echo "all the same, do nothing"
else
    echo "update exist, do rebase!"
    git reset --hard upstream/master
    git push origin master --force
fi
cd $WORKDIR && rm -rf $REPOSITORY
eval `ssh-agent -k`

这根树枝与 <upstream> .

enter image description here