(This guest blog was written by John Sparrow from Axosoft.)
Git is an increasingly essential tool to work with. Whether you’re working solo on a project and need a decent version history at your disposal, or you’re working collaboratively in a team in which you’re contributing regular updates to code, Git is an invaluable tool. But the learning curve is notoriously steep, and finding a path to understanding Git concepts can be difficult.
Part of the ethos behind creating GitKraken, a cross-platform Git GUI, was to help put Git into human terms. So take a moment, breathe deep, and read on. These are some of the irritation factors and obstacles that Axosoft developers experienced in the past, and how they solved them in GitKraken.
Line endings, eh? Can’t live with ’em, can’t live without ’em. But in truth, we rarely think about line endings as potential issues. Did you know that Windows and Linux/Mac systems use different line ending characters? This can be a problem if you are moving or sharing between operating systems in your projects. Fortunately, Git has an AutoCRLF option which will handle line endings for you. By default, Git has AutoCRLF set to ‘false’—set that to ‘true’ and be on your merry way. In GitKraken (on Windows), it’s as easy as checking/unchecking your AutoCRLF setting in Preferences > General.
Git uses something called refspec to define push behavior between local and remote branches. Git’s default behavior (if it can’t find an explicit refspec) is to push ‘matching’ branches, meaning every branch that exists locally will be updated remotely. Sounds good, right? Well, this default behavior updates all remote branches with the same name as local branches, and that can get messy. GitKraken, on the other hand, will only push the branch you select, so you won’t fall into this trap.
If you’re somewhat new to GitHub, or to working with remotes in general, understanding how remote URLs work or where to find them can be an obstacle. GitHub does make it easier to find your remote URL, but when cloning, GitKraken offers you a selection of repositories based on what remotes you have available in your service, and you can always just directly add a URL if you prefer.
Working with SSH keys is a good way of getting the best of both worlds when it comes to security and user experience; with SSH you pair up your keys with your services, set it up once, and you’re done. GitKraken has a preference section that allows you to add SSH keys to connected services, no CLI, no rsa copy-paste shenanigans.
Git really comes into its own when you’re collaborating on projects. Setting up remotes can be an annoyance, especially when you’re working with multiple remotes and upstreams. When adding a remote, GitKraken offers you a selection of forks of the currently open repository to add. In the same way as cloning a repository, you can always directly add a URL if you’d rather.
Remember refspecs? Upstreams are what we use to set refspecs for local branches. An upstream for a branch is the remote locations with which you push/pull that branch, and setting an upstream correctly is essential for workflows that incorporate pull requests into the main fork (see “Pull Requests” below). GitKraken makes it easy to set upstreams. The app will intelligently assume the most likely upstream and let you override this setting if you need to.
Working with branches is one thing, but when you want to get truly collaborative, you can work with forks, branches, and pull requests. Forking means that you have a discrete repo cloned from the original. Using this, you can work on a remote that you own, and then make a pull request to start the process of merging your edits back into the original repository. This way, you have oversight in your projects and can work independently on features and hotfixes while still being able to easily merge back in when you’re ready.
So, there you have it! Those are the 6 ways the Axosoft dev team has made working with Git easier in GitKraken. If you’re ready to make your Git life easier, download GitKraken now! Then, download Git Succinctly, Syncfusion’s free e-book, to brush up on Git concepts.