This article was originally published at Git cheatsheet
Git is a very useful skill to have and almost necessary in many companies. Browsing job...
For further actions, you may consider blocking this person and/or reporting abuse
I would like to disagree that writing git commands in the command line is hard. On the contrary, using commands is as easy as ABC especially when you have the "cheatsheet". If you want to understand git, use the command line and start to visualize the process in your head, not with UI.
While GUI might be easier, it does have learning curve as well.
I really recommend simply -- VSCode, PyCharm, IntelliJ, Android Studio, or WebStorm... That is, your GUI-based Text Editor / IDE.
I do command line mostly as well, but for beginners it can be a bit more difficult than just use GUI.
"head is the most recent commit of the repository you work with."
Even if it's for beginner and you need simplification. It's far from what HEAD really is.
Maybe you can forget what it is for beginners or you can just say "It's where you are currently". ;)
Yup!
And on that note, in my personal experience, commits and branching become much easier to understand and visualize once you think of your commit history as a linked list, and
HEAD
as a pointer that you can position at will.In fact, this is hinted at in the syntax of
git log
:HEAD -> master
, where HEAD is quite literally pointing to master (assuming that's where we are atm).Also, I agree: We shouldn't make things simpler for beginners, even if it means they may initially be confused. It's part of the learning process!
IMHO the best way to demystify what HEAD is, is to go inside the .git folder.
After that you go to the refs folder and you can explain the branches ;)
Personally I understood many things by watching inside this .git folder.
I didn't mention that, but your article is nice. I will send it to my students :)
I wrote this one about 1 years ago now -- github.com/patarapolw/SimpleGit
Actually, I have tried GitHub Desktop before, but I uninstalled.
Now I using only VSCode (Visual Studio Code). I can help with some GUI. People could probably do the same in PyCharm or WebStorm or IntelliJ-based.
Nice, useful article.
Cheat sheets are not just for beginners even if that is their focus. It's always a good idea to have quick references. Especially, with my failing memory as I get older & all the different languages I know with various syntax it's hard for me to keep together. What I find for me is I don't try to remember every little detail right away; I keep quick referencing until I know it so well I no longer need to unless I haven't done it in a few years.
I have one important problem on Git CLI on macOS...
How do I change the default text editor? I am too bad at vi. Wanna change it to Nano or Code or something.
Otherwise, I will need vi cheatsheet as well, even when productivity doesn't matter.
You can setup default editor in the .bash_profile or .zshrc file in your users profile :)
Thanks, found it. A better way, actually.
And,
git config --global --edit
, of course.Great one - i would recommend to add the word „locally“ at the description for the branch delete command with the small „-d“.
While this may be "very basic" introduction, it is confusing. Nothing is explained in detail on how things work and relate to each other.
After reading this article you might be able to manage a single repository of configuration files on your own computer, that's it. For a software developer part of a team this is simply not even a start.
In a company with a team of SW developers you:
I just named about 30 new terms you need to know how to use, know all of their command line parameters and be aware what changes they do to your refs, files, index, branch or repository.
Confused? No wonder. Git has so many commands, terms and parameters that you can generate random legit looking git man pages without noticing that they are nonsense jokes. Just have a look at this "Git random man page generator" git-man-page-generator.lokaltog.net/
Thanks for doing this! I was about start writing something similar. I want add to GUI list something useful I used to work with every day
Git Graph extension
I've been using Git for about 10 years and started using GUIs early on. I started going command line only as of 6 months ago and love it because you really learn the underpinnings of Git which is abstracted away by most Git GUIs.
Great article.
Very use full. Thanks for writing.
Thanks for the cheatsheet but what theme is in the header cover?
Some modified monokai or flat material.
I have been using gitk!
I stopped reading here:
"repository keeps all your project's files, including commits and branches.
branch is a copy of the repository ..."
So the repository holds copies of itself?
I would say yes, without going deep into "how git works inside", when you create a new branch, you create a new version, something like copy of code from the branch which is the parent for your new branch.
A copy of a branch, yes. But not a copy of the whole repository (which would be impossible, since copying the whole repository into itself would be subject to recursion).
en.wikipedia.org/wiki/Russell%27s_...
I actually like using VSC with Git Lense etc - vs like sourcetree etc..
This is great
Great one. This will certainly help beginners!
If someone is interested, I automated some of the git commands on my automation repository and this is great!