... | ... | @@ -8,7 +8,34 @@ By default, every repository has at least one branch, which is called Master. If |
|
|
If a new branch is created, the version history bifurcates at this point and is being kept separately for Master and the new branch. Users can synchronize local clones with either of them (this process is called checkout) and can commit and push to one or the other (provided that they have permission to push to the Master branch -- the project owner can restrict the permission to that). At a later stage, if it turns out that the content of the new branch is useful, it can be re-included into the Master branch -- this is called Merging.
|
|
|
|
|
|
**Creating a new branch**
|
|
|
In the following, we assume that you have access to a repository called MyProject on OpenVT, which you have readily cloned to your own computer. Open a terminal and browse into the respective folder. In order to make sure to have the latest version of the content, do a
|
|
|
In the following, we assume that you have access to a repository called MyProject on OpenVT, which you have readily cloned to your computer. Open a terminal and browse into the respective folder. In order to make sure to have the latest version of the content, do a
|
|
|
|
|
|
```bash
|
|
|
git pull
|
|
|
```
|
|
|
Now, we will create a branch called MyBranch:
|
|
|
```bash
|
|
|
git branch MyBranch
|
|
|
```
|
|
|
|
|
|
This will now be created both locally (in your clone) and on the remote repository - also called origin. You can choose the branch that you are working on by doing
|
|
|
```bash
|
|
|
git checkout <branch_name>
|
|
|
```
|
|
|
where branch_name could be master or MyBranch in our case. If you check out MyBranch, you can do any modifications to its content as usual. When appropriate, you can push your modifications to the remote repository by doing the usual steps
|
|
|
```bash
|
|
|
git add .
|
|
|
git commit -m 'commit message'
|
|
|
git push origin MyBranch
|
|
|
```
|
|
|
The last line tells git to push the changes to the remote version (origin) of MyBranch. In case you have forgotten on which branch you are or you would like to know about not yet pushed commits or changes yet to track or commit, the command
|
|
|
```bash
|
|
|
git status
|
|
|
```
|
|
|
will tell you all that.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
... | ... | |