Warning: this only works in GIT version >= 2.23
In older versions of GIT when you wanted to create a new local branch a track changes from a remote branch (say develop), you would have to use two commands:
Since GIT 2.23 you can use a single command to achieve the same:
The first time you use GIT you will get a warning when you try to pull in changes from a remote repository. GIT will use the default strategy (pull.rebase false) which causes changes to be applied with a merge commit.
You can change the default strategy to pull.rebase true by using the following command:
The first time you use GIT you will get an error when you try to push changes to a remote repository.
This happens because GIT doesn’t know which remote branch matches the local branch you’re trying to push.
To avoid this error you can follow the advice in the error message, however you would have to do this for each new branch you want to push to the remote repository. You can also make this behavior permanent by updating your default push strategy in your global GIT config using the following command:
This push strategy pushes the current branch to update a branch with the same name on the remote repository. If the branch doesn’t exist on the remote repository, it gets created.