Git has two types of branches: local and remote . To use git pull and git push as you wish, you must tell your local branch ( my_test ) where the remote branch is tracking it. In typical Git mode, this can be done both in the configuration file and with commands.
Teams
Make sure you are on the master branch with
1) git checkout master
then create a new branch using
2) git branch --track my_test origin/my_test
and check it with
3) git checkout my_test .
You can then push and pull without specifying local and remote.
However, if you already created a branch, you can use the -u switch to tell Git push and pull that you want to use the specified local and remote branches from now on, like so:
git pull -u my_test origin/my_test git push -u my_test origin/my_test
Config
The remote branch tracking configuration commands are fairly straightforward, but I list the configuration method and it is also easier for me if I create a bunch of tracking branches. Using your favorite editor, open the .git/config project and add the following.
[remote "origin"] url = git@github.com:username/repo.git fetch = +refs/heads/*:refs/remotes/origin/* [branch "my_test"] remote = origin merge = refs/heads/my_test
Indicates a remote call to origin , in this case one GitHub style, and then tells my_test use it as a remote one.
You can find something very similar to this in the config after executing the above commands.
Some useful resources:
ghickman Sep 05 2018-11-22T00: 00Z
source share