Skip to content
Snippets Groups Projects
get-the-source-code.pandoc 2.84 KiB
Newer Older
  • Learn to ignore specific revisions
  • +++
    date = "2018-02-23T15:28:13+01:00"
    title = "Get the source code"
    author = "Lars Bilke"
    weight = 1003
    
    [menu]
      [menu.devguide]
        parent = "getting-started"
    +++
    
    ::: {.note}
    ### Attribution
    
    The content of this page is largely taken from the [GitHub-blog](https://github.com/blog/2042-git-2-5-including-multiple-worktrees-and-triangular-workflows).
    :::
    
    
    ## Create a fork
    
    Go to the [official OGS-6 repository](https://github.com/ufz/ogs) and click the "Fork"-button. This creates a new fork under your account with the URL `https://github.com/YOUR-USERNAME/ogs`.
    
    
    ## Setup your local clone
    
    You can use the git command line tool to clone the remote repository on GitHub to your PC:
    
    ```bash
    $ git clone https://github.com/YOUR-USERNAME/ogs
    $ cd ogs
    $ git config remote.pushdefault origin
    $ git config push.default current
    ```
    
    **Note:** We use `git lfs clone` instead of the regular `git clone` to significantly speed up the cloning of the repo and its test data files. See [this for more information](https://github.com/ufz/ogs/pull/1978).
    
    This creates a new folder `ogs` in your current working directory with the OGS source code. After this step, the remote called `origin` refers to your fork on GitHub. It also sets the default remote for pushes to be `origin` and the default push behavior to `current`. Together this means that if you just type `git push`, the current branch is pushed to the `origin` remote (git version >= 2.5 required).
    
    Create a second remote called `upstream` that points at the main OGS repository and fetch from it:
    
    ```bash
    $ git remote add upstream https://github.com/ufz/ogs
    $ git [lfs] fetch upstream # The lfs-equivalent of the fetch command is more efficient
    ```
    
    
    ## Optional: Working on a new feature
    
    You only have to follow the above steps once. From then on, whenever you want to work on a new feature, you can more easily interact with the remote repositories.
    
    Make sure that your local repository is up-to-date with the upstream repository:
    
    ```bash
    $ git fetch upstream
    ```
    
    Create a branch `feature-name` off of upstream `master`-branch to work on a new feature, and check out the branch:
    
    ```bash
    git checkout -b feature-name upstream/master
    ```
    
    This automatically sets up your local `new-feature`-branch to track the upstream `master`-branch. This means that if more commits are added to `master` upstream, you can merge those commits into your `feature`-branch by typing
    
    ```bash
    $ git pull
    ```
    
    or rebase your branch on top of the new master by typing
    
    ```bash
    $ git pull --rebase
    ```
    
    Now after you implemented the feature and committed your work you can push the new commits to the `feature-name`-branch on your GitHub fork:
    
    ```bash
    $ git push
    ```
    
    If your work is done submit a pull request.
    
    This workflow is summarized with this picture:
    
    ![](https://cloud.githubusercontent.com/assets/1319791/8943755/5dcdcae4-354a-11e5-9f82-915914fad4f7.png)