Skip to content

Getting Started with Development

Alvin Zhang edited this page Feb 13, 2020 · 7 revisions

The following guides will be useful for those new to software development with GitHub:

https://guides.github.com/activities/hello-world/

https://guides.github.com/introduction/git-handbook/

There are other guides as well which can be found in https://guides.github.com/.

Getting Started

The following are instructions for getting started with development on the Proteus project:

1. Fork the repository

On the project homepage, click on the Fork button in the upper-right corner. This will make a copy of the Proteus repository in your GitHub account. This copy will have identical branches as the original repository but it will not track the original repository. So updates on the original repository will not be reflected in your fork by default. This is not a huge issue because we can handle that with remotes discussed in section 3.

2. Clone the fork

Make a local copy of your fork.

3. Add the original repository as a remote

When you push/pull changes into your local repository, it is done based on a remote repository (the one on GitHub). You can check which remotes are associated with your repository through git remote -v. By default, there will be a remote named origin which is associated with where you cloned your repository. You can add the original repo as a remote as well through

git remote add upstream git@github.com:erdc/proteus.git.

You can then get updates from the upstream remote through

git fetch upstream.

The keyword upstream was arbitrarily chosen; it can in fact be anything you choose (e.g. radish, puppy, originalRepo, etc.).

4. Checkout master and making a feature branch

Once you've added the remote and updated it, you can start developing based on the master branch:

git checkout upstream/master

You now have a local copy of the original repository's master branch. If you want to add additional features, you can do

git checkout -b nameOfBranch

and then make the commits as usual. When you need to push to a remote repository, you should push to origin, your fork of the original repository:

git push -u origin nameOfBranch.

5. Pull requests

From the fork, you can then start a pull request against the original repository with your feature branch.

The process may seem unnecessarily long, but it helps keep the original repository free of unnecessary branches and of unintended changes.

Rebasing off Master for Pull Requests

In the event of a history rewrite, you can salvage your local feature branches that have different history through rebasing. The goal of rebasing is to take the commits that are relevant to your feature branch and apply it in order to the head of the master branch. There are good resources to help understand this approach such as Atlassian.

Assuming you've set up a fork and updated the remotes, checkout a local branch that tracks the master branch of proteus.git

git checkout upstream/master

Then create a copy of this branch

git checkout -b trackingMaster

Now checkout your feature branch (you might have to use the -f)

git checkout featureBranch

Make a copy of that branch

git checkout -b featureBranch_rebase

Now rebase interactively

git rebase -i trackingMaster featureBranch_rebase

This will bring up a list of commits that you can keep or discard in an editor. You need to find all the commits that are unique to featureBranch and discard the remainder of the commits. Once the final list is obtained, you quit the editor and the rebasing operation begins. For each commit, you may need to resolve conflicts. Do so carefully, add the conflicting files, and then continue with git rebase --continue