chriswalz / bit

Bit is a modern Git CLI
Apache License 2.0
6.05k stars 106 forks source link

feature: setup fork command #89

Open joe-getcouragenow opened 3 years ago

joe-getcouragenow commented 3 years ago

when a developer clones their fork, the first thing they do is setup the config.

it can be automated with "git remote add upstream git@$(GITR_SERVER)-$(GITR_USER):$(GITR_ORG_UPSTREAM)/$(GITR_REPO_NAME)"

this presumes that your using ssh .

wondering if you think its a good idea to add... ?

chriswalz commented 3 years ago

This sounds useful but since I don't clone/fork very often I don't quite understand. Similar to the previous issue can you please write the "Current Workflow" and the "Proposed Workflow"

herbygillot commented 3 years ago

Say I click the Fork button on your bit repo here on Github.com. It will create a new forked repo for me, herbygillot/bit.

Now if I clone that forked repo down to my machine to hack on, then origin (the default remote destination) will automatically be pointing to herbygillot/bit.

If I push any code changes, they'll go to my forked repo by default.

But since main development is happening in the original repo, chriswalz/bit, then I'll need to add that as a remote so that I can sync the latest changes.

So I add the original repo chriswalz/bit using git remote add:

$ cd <path to my checkout of herbygillot/bit>
$ git remote add upstream git@github.com:chriswalz/bit.git

This adds a new remote destination named upstream, pointing to the original repo (yours).

Now if I need to pull the latest changes from your repo down to my local checked out code, it would look something like:

$ cd <path to my local checkout>
$ git pull upstream/master

If I list my remotes, I should see origin pointing to my repo, and upstream pointing to yours:

$ git remote -v
origin ...herbygillot/bit
upstream ...chriswalz/bit

gh has a fork command that when specified against some repo HTTPS or Git SSH URL, forks it under your username on Github.com and optionally clones it down locally (--clone).

$ gh repo fork git@github.com:chriswalz/bit.git --clone