P. Mergey
P. Mergey

Reputation: 343

About managing branches into a GitHub clone

By mistake, I've recently "deleted" a branch into a clone that I've forked on GitHub. After noticing this error, I've tried to "reactivate" this branch, but I've realized that this action seemed to create a "pull request" into the upstream repository. Therefore, I've decided to definitely delete this branch into my clone, in order to not affect the upstream source in any way.

After this "misadventure", I have some questions about management of branches into a GitHub clone:

  1. can I safely delete a branch in my clone (especially if this branch seems no longer active in upstream)?
  2. is it possible to fully synchronize all the branches (default, active and stale branches) from upstream into my clone?
  3. is it better to keep only a unique master branch into my clone (in particular if my goal is mainly to stay updated from upstream)?
  4. can I create a specific branch into my clone without affecting upstream in any way (as automated pull request)?

Upvotes: 1

Views: 61

Answers (1)

VonC
VonC

Reputation: 1323243

can I safely delete a branch in my clone (especially if this branch seems no longer active in upstream)?

Yes, the original repo (forked by your clone) won't be affected

is it possible to fully synchronize all the branches (default, active and stale branches) from upstream into my clone?

That is usually done on your machine: your local clone of your fork has two remote:

  • origin: your GitHub fork
  • upstream: the original repo (git remote add upstream https://github.com/<user>/<repo>)

You can fetch from upstream, and reset --hard any local branch you branch to upstream/<branch>. And then push to origin.
That is different than updating a new branch dedicated for a PR: see "Troubleshooting the workflow to incorporate upstream changes into forked repo".

is it better to keep only a unique master branch into my clone (in particular if my goal is mainly to stay updated from upstream)?

You can keep any branch you want on the clone. What matter is the additional branch you create in order to fix a bug: the PR should be done from that new branch.
That is what I mention in "couple of tips for PR (Pull Requests)".

can I create a specific branch into my clone without affecting upstream in any way (as automated pull request)?

Yes you can: again do so on your local clone on your machine, then push to your fork, and do your PR from the fork on GitHub.

Upvotes: 1

Related Questions