yeahhhmat
yeahhhmat

Reputation: 41

git pull from remote master branch

  1. I forked a repo on GitLab
  2. Cloned my fork to my local machine
  3. Made some changes, then pushed to my fork.
  4. Some changes have been made on the original repo and I want to git pull so everything is up to date.

Is this possible?

I've tried git pull and git pull origin master and got everything is up-to-date. (makes sense)

git pull upstream gave me the following message:

You asked to pull from the remote 'upstream', but did not specify a branch.

I don't know how to specify these branches, everything thing i've tried returns branch does not exist. But I feel this is the right direction..

Branches:

 * master
 remotes/origin/HEAD -> origin/master
 remotes/origin/master

I'm not sure the difference between these two branches. Or which one is the original repo to begin. I'm all out of git pull ideas and feel there might be something else I'm missing?

Upvotes: 1

Views: 3454

Answers (1)

CodeTalker
CodeTalker

Reputation: 1791

Method 1

  1. Checkout in your forked repo in the branch you wish to pull into (preferably master).
git checkout master
  1. Pull the repo in your repo's branch using absolute path
git pull https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git BRANCH_NAME
  1. Handle merge conflicts if any.

  2. Commit the merge and push to master

git commit -m "pulled parent repo"
git push origin master

Method 2 1. Go the root directory of project. 2. Fetch the branches and their respective commits from the upstream repository. Commits to master will be stored in a local branch, upstream/master.

git fetch upstream
  1. Check out your fork's local master branch.
git checkout master

4.Merge the changes from upstream/master into your local master branch. This brings your fork's master branch into sync with the upstream repository, without losing your local changes.

git merge upstream master

Upvotes: 2

Related Questions