Skip to content

fetch and push with different repositories#1198

Merged
aollier merged 1 commit intoprogit:masterfrom
aollier:fetch_push
Mar 11, 2019
Merged

fetch and push with different repositories#1198
aollier merged 1 commit intoprogit:masterfrom
aollier:fetch_push

Conversation

@aollier
Copy link
Contributor

@aollier aollier commented Mar 9, 2019

Added a section that explains how to fetch from one repository and to push to another one.

@ben ben mentioned this pull request Mar 11, 2019
@ben
Copy link
Member

ben commented Mar 11, 2019

See 9a48cda for my suggestions.

@aollier aollier merged commit 4bcbaea into progit:master Mar 11, 2019
@aollier aollier deleted the fetch_push branch March 11, 2019 10:17
@Splarv
Copy link
Contributor

Splarv commented Mar 11, 2019

May be this is matter of taste, but I think that will be better mark an origin repository as "origin" and a fork repository as "fork". And so the default configuration for a common GitHub user will be as simple as:
git clone origin_url
git remote add fork fork_url
git config remote.pushDefault fork

@ben
Copy link
Member

ben commented Mar 11, 2019

Naming is one of the hardest problems. 😁

Naming remotes after their fork names scales to more than one fork, which is nice as a maintainer when you have three or four forks you pull from regularly.

@Splarv
Copy link
Contributor

Splarv commented Mar 12, 2019

May be there are different use cases, at least two: a common submitter without write access and common maintainer. And each use case may suggest different scheme or workflow which will be mostly convenient. I don't know what workflow is better for a maintainer. But I think that an example of the workflow of the common newbie submitter must be clearly mentioned, because it is a newbie who poorly understand how to use git for his purposes.

I think that my workflow for the newbie is much more natural and clear:

  1. The original repository is called "original".
  2. The fork repository is called "fork".
  3. In this workflow the fetch (pull) is always from the original repository. No one need to pull from the own fork repository. And so is the default behaviour of an original repository in git. (Git fetch all branches from an original by default.)
  4. But all pushes must always go to the own fork repository (to create a pull request) and so is for the remote.pushDefault option.

So is a common workflow for the newbie submitter will be:
create fork repository on GitHub site
git clone origin_url (and so all branches will be fetched from the origin repository by default)
cd directory_of_repository
git remote add fork fork_url
git config remote.pushDefault fork _(and so all branches will be pushed to the fork by default)

for each feature repeat:
git checkout -b my_feature_branch origin/master (or another project depended mainstream branch, which is needed)
do some work, after commit:
git pull --rebase
git push
_create pull request for the "my_feature_branch"

In case of the committed example:

create fork repository on GitHub site
git clone fork_url (the fork will have name origin and all branches will be fetched from the fork by default, IMHO useless)
cd directory_of_repository
git remote add origin_name origin_url (origin repository will be named origin_name)
git config remote.pushDefault origin

for each feature repeat:
git checkout -b my_feature_branch origin_name/master (or another project depended mainstream branch, which is needed)
do some work, after commit:
git pull --rebase
git push
_create pull request for the "my_feature_branch"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants