Git is a version control software created by Linus Torvalds (also responsible for giving us Linux). There are different commercial implementations of git. Even though, as some say, the time has come to give up GitHub, the following notes still refer to Github. There is also a lawsuit against Github which is motivated by Github building its success on becoming the repository of open source software development and then, as some claim, abusing the trust that open source developers brought to the platform. I had no time to look into Resources to Give Up GitHub myself yet, but if you want to try alternatives have a go.
Have a look at this tutorial. Let me know if there are problems or if you have other helpful sources.
Watch the video of the MIT Missing Lecture Series on Version Control (Git). (Btw, all of the series is highly recommended.)
I collect here some lessons learned from using git for assignments in various courses.
Proper use of git will be considered for grading. Depending on the nature of the assignment, complete solutions uploaded to the repo just before the deadline and not containing a trail of your work may not be accepted for grading.
- Use the repo to create a trail of your work. Commit and push often.
- Be careful about what you commit:
- Do not track/commit/push machine generated files.
- Avoid unthinking use of
git add *. Only add files that should be tracked. - Run
git status. If you see underUntracked filesnames that you don't recognize, they are likely machine generated files. Do not track those. Rather add these names to a file named.gitignoreat the root of your repo. - Build up your
.gitignoreincrementally usinggit statusand add files you do not want to track to.gitignorestep by step. You can start from my .gitignore file in this repo. - Meaningful commit messages will help yourself and collaborators.
- Do not create different versions of files by copying them. Use branches for collaborative projects in which you and your collaborators want to work simultaneously but independently on the same project. Branches can be merged later.
- Delete files only in exceptional circumstances. (Btw, even deleted files will remain accessible via the history.)
The links below are written for more complex projects than a typical assignment, but it cannot harm to have a look:
- The Git Community Book
- Commit Often, Perfect Later, Publish Once: Git Best Practices
- Examples of gitignore files
- Some pages from
- github.com
- git-scm.com:
- Getting a Git Repository (clone)
- Working with Remotes
- Contributing to a Project (fork) (probably not relevant for us)
- Further information:
- To throw away all uncommitted local changes:
git fetch origin git reset --hard origin