Git commands

Github is a great place to host code, whether you use it to manage changes, post a final(-ish) version of code, or collaborate and share with others. It can be easier to use git than to email scripts, or point someone to a script on the supercomputer.

Expand all

Starting a repo

Starting a repo

First, you can create a directory (on any computer) and put some files into it. Then to initiate a repo, install git and run something like

Then, to add all the files, run the following (to add specific files just run git add <filename>):

Finally, to commit the files to the repo, you can run commit

Pushing to remote repository (e.g., github.umn.edu)

Pushing to remote repository (e.g., github.umn.edu)

The above has only created a repo on your local computer. To push changes to a remote repository, you first go to that remote repository using your web browser and create a new repo, but don't add anything to it at that time. Then go back to the command line and add a remote repository as follows, and push to it.

Bam! You've just pushed your local repo to the online repo.

The super usefulness of .gitignore

The super usefulness of .gitignore

Within the root directory of your repository you can create a text file named '.gitignore'. In this file you can select which file types you DON'T WANT stored in your repository, the files you want git to ignore. Some of the data with which we work is sensitive, and you don't want a copy of that sensitive data in a repository that others can see, or which you plan to release publicly! Or perhaps you don't want to clutter your remote repository on github.umn.edu with unnecessary temporary or backup files. Here's an example .gitignore file.

Branching and merging

Branches

So, you're thinking about using git to collaborate on a bit of software development. Then start thinking about bran