Git

Explore articles about git on Life Beyond Fife

git

Caveats

If this isn't the only site you've looked at for assistance learning git, you may have come across advice that perhaps contradicts some of the suggestions I've made. For example, the template workflow I describe instructs users to get the latest changes from the origin repo using git pull. Other sources will recommend, with good reason, a slightly longer approach that splits this over two git commands, fetch and merge. Opiniated versus Non-opinionated As a programmer you may have heard languages being referred to as opinionated or non-opinionated. Opinionated languages do not just specify their, often terse, syntax, but rather...

4 min readRead more →
git

Conclusion

This guide does not claim, not wants to be, an exhaustive guide to git. It attempts to give a basic mental model for what the commands are actually doing in plain English and with some simple diagrams. Complex topics such as git, of which we've only begun to scratch the surface, are mastered by learning from multiple sources and after use and experimentation in practice. Much of the power of git comes from when things don't work exactly as planned or when there's subtly different use cases for you or your collaborators situation. The inner cycle recommends making frequent commits...

2 min readRead more →
git

The inner cycle

While actively writing code and experimenting with possible solutions, it's crucial to be constantly committing code to your local git repo. By doing so you ensure you can safely undo botched attempts you might develop along the way. Indeed, this gives you the freedom to try outlandish things knowing you can easily revert to the original without needing to rely on <Ctrl>+Z in your text editor. The git commands Anytime you're happy with a small increment of coding, you can commit your changes to the local git repo. This coding increment can be of any quality you wish; it can...

2 min readRead more →
git

The middle cycle

The middle cycle helps reduce the complexity of your final commit. This daily task is to pull the latest changes from the origin repo to your git repo and merge them locally with your work in progress. Therefore, when you're ready to persist your changes to the master branch on the origin repo, many of the potential merge conflicts will likely be resolved for you by git because the task has been broken up into smaller chunks. The git commands The developer begins by completing one or more repetitions of the inner most cycle. Once some time has elapsed and...

2 min readRead more →
git

The outer cycle

The outer most cycle represents a full development task loop beginning with getting the latest code from the origin repo; developing, say, a new product feature or bug fix; and ending with creating a pull request for your changes so that they're available to your development collaborators. Your feature may take only a few hours in which case the cycle completes quickly, however, out of consideration to your colleagues if nothing else, you should break your changes into small, standalone merges that do not take more than a week to develop. The git commands First checkout the master branch. $...

2 min readRead more →
git

Setup: the origin repo

When beginning to collaborate on a coding project using git, there are a couple of steps to create a local copy of the repo. Assuming you're joining a project that's already underway, use the git clone command to create your own local copy. In the same way that master is the default name for the main development branch, origin is the default name for your shared repo server. $ git clone https://your-repo-hosting.com/repo-name.git You now have the master branch on your local machine, with a link to http://your-repo-hosting.com/repo-name.git as your origin repo. To verify the origin repo is what you expect,...

1 min readRead more →