集中型ワークフローを分散システムに適用しようとしています。集中的にではなく、ローカルで物事を行うことを考える必要があります。共有 (中央) リポジトリは、他の人と共有したいものを置いたり、他の人が共有したいものを取り出したりする場所です。
これが本質的にあなたが求めているものです。しかし、それが最良のワークフローだとは思いません。変更されたバージョンについては、以下を参照してください。
Create a new local branch (A) that tracks a remote branch (X)
git clone <url> my_repo
Do some work, make some local commits.
work, work work
git add .
git commit -m "commit of work"
A is rebased up to the HEAD of X. We're operating on the same branch
we want to rebase from the remote, so we can do it all with one command in
this case.
git pull --rebase
Do some work, make some local commits.
work, work work
git add .
git commit -m "commit of work"
Have an offshoot idea, make a new local branch (B) from (A)
git checkout -b idea
Do some work, make some local commits.
work, work work
git add .
git commit -m "commit of work"
B is rebased up to the HEAD of X
git rebase origin master
しかし....そのワークフロー全体は、「信頼できる情報源」としてのリモコンを中心に展開しています。それを行うためのよりgit的な方法は、ローカルを真実のソースと考え、中央リポジトリからの共有コンテンツで更新することです。違う角度からアプローチするだけで、同じことです。
ワークフローを実行する方法は次のとおりです。
リモート ブランチ (X) を追跡する新しいローカル ブランチ (A) を作成します。 git clone my_repo 何らかの作業を行い、ローカル コミットを行います。仕事、仕事 仕事 git add 。git commit -m "作業のコミット"
A is rebased up to the HEAD of X. We use two commands here, but doing
it this way makes it easy for me to view the differences before
doing the rebase, if I choose.
git fetch
git rebase origin/master
Do some work, make some local commits.
work, work work
git add .
git commit -m "commit of work"
Have an offshoot idea, make a new local branch (B) from (A)
git checkout -b idea
Do some work, make some local commits.
work, work work
git add .
git commit -m "commit of work"
B is rebased up to the HEAD of X
git fetch
git rebase origin/master
もちろん、どちらのシナリオも、origin/master をアイデア ブランチにリベースする前に、ローカル マスター ブランチで追加作業を行っていないという事実に依存します。そうした場合、マスターでローカルで行ったコミットがなくなり、次のようにする方が効果的です。
git fetch
git checkout master
git rebase origin/master --(make sure master is up-to-date locally)
git checkout idea
git rebase master (apply idea on top of the updated local master)