JarochoEngineer
JarochoEngineer

Reputation: 1787

Git Cloned workflow

As background, in a forked workflow, I cloned and create a fork.

I have the following:

Remote:
origin  https://github.com/user/repo.git (fetch)
origin  https://github.com/user/repo.git (push)
upstream        https://github.com/stackoverflow/repo.git (fetch)
upstream        no_push (push)

Then, I go to main branch in my fork and update the branch by rebasing:

git checkout master
git fetch upstream
git rebase upstream/master
git push

After, I go to my feature branch in my fork and update this branch:

git checkout feature
git fetch upstream
git rebase upstream/master
git push

Finally, when the push is executed I have a feature branch updated with respect to master branch and in top the changes related to feature branch are included. So far so good.

My question is how can you follow a similar workflow without fork? Suppose you have just the following:

Remote:
origin        https://github.com/stackoverflow/repo.git (fetch)
origin        https://github.com/stackoverflow/repo.git (fetch)

You have the master branch (which would merge all changes from different branches) and another branch called feature-2.

In this scenario, I just need to update feature-2 with respect to master branch. Then, should be enough to execute the following (I need to use rebase to include my changes on top)?

git fetch origin
git rebase origin/feature-2
git push

Is this correct?

Upvotes: 2

Views: 52

Answers (1)

VonC
VonC

Reputation: 1323203

In this scenario, I just need to update feature-2 with respect to master branch.

Then you would need to rebase on top of the updated remote master:

git fetch origin
git switch feature-2
git rebase origin/master
git push --force

Upvotes: 1

Related Questions