Skip to content
Snippets Groups Projects
Commit 9a9f3a95 authored by Mactavish's avatar Mactavish
Browse files

add tracking branches

parent 9c1c233e
Branches
No related tags found
No related merge requests found
......@@ -323,6 +323,26 @@ git checkout -b <new branch name>
git checkout -b <new branch name> <some other exisiting branch>
```
#### Tracking Branches
Lets say you are working on a branch named `dev` which you fetched from the remote named `origin`. Now you want to work on this branch for a quite a long time and want the `git push` and `git pull` using the `dev` branch of `origin` by default. So that you won't have to type `git push origin dev` or `git pull origin dev` every time you want to update or pull the updates to and from the remote branch.
First, you need to tell Git which branch to track:
```c
# suppose you are on the dev branch on you local machine, and there is already a dev branch in the remote repo
git branch --set-upstream-to origin/remote
```
This only works when there is already a `dev` branch in the remote repo. If you want to create a new branch in the remote repo, and track it automatically, then you can use the following command:
```
# this will create a dev branch in the remote and track it using the current branch locally
git push --set-upstream origin dev
# or, same as above
git push -u origin dev
```
#### Merging Branches
Merging in Git is the way to putting forked history back together again. The `git merge` command lets you integrate branches created by `git branch` into a single branch.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment