I think that there is a misunderstanding between the concepts repo
, branch
and remote
here.
From my understanding you want to "pull a local branch into another local branch" (ie. "pull" a branch, not a repo).
pull
is normally not terminology we use for local branches (a pull
operation involves fetching something from a remote repo).
If this is what you want to do, there are two options:
- You can use e.g
git merge my_task_branch
to merge the my_task_branch
into the current branch.
- You can use
git rebase master
to move the changes that you have made on the current branch, so that they are based on the latest change on the local master
branch.
Both these options will ensure that the changes on the other branch (my_task_branch
/master
in the examples above) are made available in the current branch.
Some terminology:
Repo: A repo has one .git
directory. If you have two repos, they (per definition) have two different .git
directories, otherwise, they are the same repo.
When you are saying "both branches are of the same project, so they have the same .git
file", you mean that both branches are in the same repo.
Branch: A repo can have multiple branches. Each branch represents a history of changes which may be different. You can make some changes to one branch, commmit them. And then checkout another branch to
make some other changes there.
Remote: A remote is a reference to another repo from/to which you can fetch/push changes.
Pull: A git pull
operation has two parts. First, commits are fetched from some other remote repo (this can be done separately with git fetch
command). Thereafter, some branch from the remote repo is merged into the current branch (git merge
command)
Local branch vs Remote branch: You can create any number of local branches in your repo. But a local branch is different from a remote branch. You can create any number of local branches without impacting the remote repo in any way. The local branches only become visible in the remote repo if you git push
those branches.