Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pull local master into local branch

Tags:

git

github

I have a remote origin/master and a remote branch remote_branch. I also have local master and a local branch local_branch. When I try to pull the local master into the local_branch with git pull master local_branch I get this.

fatal: 'master' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

However, when I do git branch I see this:

* loca_branch
  master

Why can't I pull from my local master?

like image 247
Stophface Avatar asked Sep 20 '16 16:09

Stophface


People also ask

Can I git pull a local branch?

Using git pullUse git pull to update a local repository from the corresponding remote repository. Ex: While working locally on master , execute git pull to update the local copy of master and update the other remote tracking branches.


2 Answers

merge changes from local_branch TO master

git checkout master
git merge local_branch

merge changes from master TO local_branch

git checkout local_branch
git merge master

Pull is when you have an 'origin' repo :)

like image 113
SantiG Avatar answered Oct 17 '22 03:10

SantiG


git pull is an alias for git fetch && git merge you cannot fetch from local branches (only from remotes) - actually you don't need to, if your intention is to merge master into local_branch, just use git merge master when you are on local_branch.

like image 36
Shmulik Klein Avatar answered Oct 17 '22 01:10

Shmulik Klein