Let’s face it, understanding Git is hard. And it’s hardly fair, really; up to this point, you’ve already learned a variety of different coding languages, you’ve been keeping up with what’s on the cutting edge, and then you find that Git has its own mess of terms and words!
What is the hardest thing to learn about Git?
So, we asked you, our Twitter community, “What is the hardest thing to learn about Git?” Here are our answers to some of the responses we received.
#1: What’s the deal with having a remote repository and a local repository?
— Uri Goldstein (@urig) August 18, 2016
Repos are the files in your project, along with a history of those files. The history of your repo is comprised of commits–snapshots of the states of your repo files at discrete points in time.
You can have a local repo that sits on your machine, and basically keeps a history of your changes at certain points in time, so you can revert if you need to. But things get more complex when you have both a local and a remote version of a repo.
Hosting a repo on a remote service such as GitHub means that devs can all contribute to the same repo, working on their local repos and then reflecting those changes on the remote. Pulling from a remote repo will update your local repo so it’s up-to-date with the remote. Pushing to a remote repo will incorporate your local changes so that others can pull them down to their local repos.
This means that rather than checking out files, working on them, and checking them back in (remember doing that with Dreamweaver, non-millennials?) team members can work on the same files simultaneously and merge changes together via the remote.
Once you grasp this idea, it will become second nature. Just remember: “pull before you push.”
#2 Why are some resets soft and some are hard?
Yeah, about that… sigh. Let’s dig in: the difference between `git reset` with
hard is basically the following:
soft leaves both your working directory and your index untouched.
hard resets all your work.
— alexmaday (@alexmaday) August 18, 2016
What that means is that anything you had staged/unstaged stays where it was and all the changes between your previously checked out commit and the reset-to commit are put into staged.
mixed leaves your working directory untouched, but resets your index to that commit.
Basically, it resets you to that commit and then unstages everything, regardless of what you had staged.
hard resets everything. Any work you had in your working directory is blown away. To be clear, that means all commits on your current branch that aren’t held in the history by another commit, either remotely or locally, are also lost (short of using some Git reflog voodoo).
For beginners, the difference between
hard is the most important distinction to make.
#3: How do I grasp this idea of rebasing and merging? HALP!
@GitKraken the concept of rebasing can be hard
— Josh Medeski (@joshmedeski) August 18, 2016
This is best explained visually. Check out this super short video that explains it all. Special guest Chris Bargren, GitKraken Dev, walks you through it.
#4: Dealing with merge conflicts make me feel like I’m in a tough relationship. Any advice that doesn’t include a breakup?
Let’s deal with this on a case by case basis. Yeah, most times you can talk it through and work it out. Sometimes, sadly, you have to say goodbye and start from scratch. Yes, I’m talking about your relationship and Git.
— Brandon (@brandonscript) August 18, 2016
A merge conflict occurs when you try to merge two branches with changes on the same line of the same file. For example, file “A” changed in one area and also changed in another area. If the change exists on two different lines, it’s no sweat. However, if the change is on the same line, we have a problem, and now it’s up to the user to decide what to do.
Fortunately, there are tools that can help you in different capacities (short from couples therapy). Most Git clients and the CLI will tell you when there’s a conflict, and dedicated merge tools will help you edit those changes.
However, GitKraken’s interface shows you where the conflicts are and asks you how you want to merge, in a very visual way. In GitKraken Pro, you can not only merge gracefully, you can choose the affected line and edit it without getting out of the tool. No painful breakups today, my friend!
#5 I’m a command line purist. I won’t ever leave it, but I’m frustrated with the amount of new stuff I have to learn. Any tricks?
I get it. You love the CLI. You can see all the commands working underneath the hood, or covers, or whatever metaphor you want to use. You say you’re just wired like that. Ok, that’s cool. Aside from time and training, there’s not a lot that can be done to speed up the process of learning it. In GitKraken, we make it so you don’t have to see what commands are happening.
You heard that right. You don’t need to know every command in order to get the job done, and I’m here to tell you that’s not a cop-out. You’re not less of a dev. Now, go look in the mirror and tell yourself that.
— Jonathan Storey (@jonistorey) August 18, 2016
GitKraken aims to make it so you don’t need to know everything that is happening “under the hood”. You don’t need to have it in your brain that you are running Git rebase branch A and branch B. You don’t have to remember that the command to take back that last commit you accidentally made is
git reset --soft HEAD~1. You just right-click that commit and
Reset -> Soft. You don’t have to dig through the output of
git reflogto undo that accidental
git reset --hard. That’s a simple click of the undo button.
So, if you’re starting to think that there might be a better way; that the CLI might not be the be-all-end-all; that maybe there is one special GUI that could pull you away from the CLI. We want to tell you: it’s okay! It’s okay to want to get work done quickly and efficiently and save some of your memorization skills for party games. You’ll find that doing work in GitKraken is actually easier (and come on, who doesn’t want that?)
Other Git GUIs may have burned you in the past, because yes, while they do make the work more straightforward, it’s not necessarily faster. We dare you to give GitKraken a try, and see if it’s the one!