More Stuff

The basic workflow is everything you need to version control your own work in personal repositories. Of course, things get more complex when collaborating with a team or contributing to a project. There is LOTS more to learn about Git and workflow strategies!

Here are a few suggestions for the next topics to master:

git branch

Branching is a Git fundamental that allows you to test out ideas in parallel to your main repository without disrupting the master copy. Using branches strategically figures into many collaboration workflows, such as Github flow. Often, the master branch is considered functioning, production ready code. Additional branches are created to develop and test new features. When the new features are ready, the development branch can be merged into the master.

git branch test-branch 
git branch --list
git checkout test-branch
git checkout -b another-branch
git branch -D test-branch

git merge

Once you have branches, you will want to merge them together. Luckily, Git has tools to automate merging. If it encounters a line that can not be automatically merged, Git will mark the file for you to manually fix before proceeding. For details, check the Git Book Basic Branching and Merging.

git checkout -b new-branch
echo "new stuff" > newfile.txt
git add newfile.txt
git commit -m "new stuff"

git checkout master
git merge new-branch
git branch -D new-branch

.gitignore

Sometimes there are files that you do not want version controlled or sent to your remote repository. Create a .gitignore file in the repo to tell Git to ignore things. Global ignores are generally added by the Git installer, and local ones are often automatically generated by project templates or your IDE. For details, check this gitignore tutorial or the documentation.

GitHub Fork and PR

Forking a repo on GitHub, editing, then opening a Pull Request (PR) is a common workflow for collaborating on bigger projects. Understanding how to fork and create a PR will allow you to contribute to open source or manage a centralized project for your team. Check the Forking Projects guide for an demo example, or the BitBucket PR tutorial.

Many projects will have a contributing guide, details are often listed in a file named CONTRIBUTING, to help you understand how they handle PRs or Issues. For more information, check the How to Contribute to Open Source guide.

For an overview of workflows that might help your team collaborate, check BitBucket’s Git Workflow Tutorial.

GUI

There are a variety of GUI apps available for managing and visualizing Git repositories. However, one of the most handy methods is to use a good text editor with Git support built in.

gh-pages

GitHub Pages is a quick, easy, and free way to host static web pages. It can help you showcase your project, share your documentation, create a lab website, or start a blog.

GH-pages is enabled from the “Settings” for a repository. There is three options:

Once published your website will be [username].github.io/[repositoryname]

For example, https://evanwill.github.io/get-git/

Check out this intro workshop go-go gh-pages for more info.

Citable Code

GitHub repos can be integrated with Zenodo to issue a DOI. DOI are a persistent identifier used in academic writing to cite articles and other works. Having a DOI for your code makes it easier to track citations and impact. Learn how at Making Your Code Citable.