DEV Community

Cover image for Git fundamentals, a complete guide

Git fundamentals, a complete guide

Leandro Proença on March 15, 2023

If you already work with Git daily but want to have a good comprehension of Git fundamentals, then this post is for you. Here, you'll have the cha...
Collapse
 
rajhawaldar profile image
Raj Hawaldar •

Hey @leandronsp, your blog writing skill is outstanding. Great Post!

Collapse
 
leandronsp profile image
Leandro Proença •

I appreciate Raj <3

Collapse
 
julitroalves profile image
Julio Alves •

Great article, thanks!
It's worth noting that you must never do git rebase main when working on a repository with other coworkers because it gonna rewrite all the commits hash and throw conflict merge with all team members.

Collapse
 
leandronsp profile image
Leandro Proença •

Indeed, I should’ve used git rebase fix instead, well spotted!

Collapse
 
deadjdona profile image
Dead J. Dona •

how did you get these files inside git-101 folder?

Collapse
 
leandronsp profile image
Leandro Proença • • Edited

I created them manually, they aren’t the focus of the article.

Collapse
 
deadjdona profile image
Dead J. Dona •

it would be interesting to know how to do this, and also have exact structure that need to be created.
ls -F1 .git/
shows nothing to me, so I didn't read after that.

Thread Thread
 
leandronsp profile image
Leandro Proença •

did you run git init in the folder as suggested in the guide?

Collapse
 
benlopes profile image
Ruben Lopes •

You are a great teacher! Have you ever considered about developing an algorithms & data structures course/material? I myself would pay in advance for that! Anyways, thanks a lot for this git fundamentals guide!

Collapse
 
leandronsp profile image
Leandro Proença •

Hi Ruben, I appreciate your words <3

I've never considered creating such material, for now I'm just dumping thoughts on blogposts, but thanks for enlightening me!

Collapse
 
wooncherk profile image
Lam Woon Cherk •

Great post! 😊

Collapse
 
romil_code profile image
Romil Jain •

Hey, That was really great article and really took a deep dive into the topic

Collapse
 
mfurmaniuk profile image
Michael •

Nicely done, its good to review the basics of the git now and again as some of these I used a lot years ago (like cherry-pink) but haven't for a long time.

Collapse
 
staalezh profile image
Ståle Z.H •

Great post!

Collapse
 
samuel_marien profile image
Samuel Marien •

Thank for this amazing article, clear and detailed !

Collapse
 
quinsulonphd profile image
Quinsulon Israel, PhD •

Thank you for a succinct look as some of the ignored or less thought about inner workings of git.

Collapse
 
parmcoder profile image
Possawat Sanorkam •

This is exactly what I would want to see with git 101. You will help a lot of CS kids in their classes with this. Thanks man! Well written!

Collapse
 
leandronsp profile image
Leandro Proença •

Thanks, that's exactly my goal writing these articles, bring fundamentals in a language easy to grasp. CS fundamentals don't need to be like black magic where only CS wizards can understand, that's why I work to fight that misconception about CS fundamentals

Collapse
 
manjunani profile image
Manjunatha Sai Uppu •

Thanks a lot for the detailed Info @leandronsp

Collapse
 
kauefraga profile image
Kauê Fraga Rodrigues •

Thank you a lot, Leandro! This article helped me to understand how Git actually works

Collapse
 
r_john_victor profile image
R John Victor •

Explained it very clear. Thanks for posting

Collapse
 
abdorah profile image
Kotbi Abderrahmane •

This is a great article, thank you and keep the good work!!!!

Collapse
 
renanborgez profile image
Renan Borges •

incredible post,thanks

Collapse
 
mino profile image
minoblue •

Great Article :)

Collapse
 
linhtv26 profile image
Tran Van Linh •

Awesome article!

Collapse
 
jonnius profile image
Evgenii • • Edited

for those who are interesting how to get "tree" option for the command
$ git commit-tree 3725c -m 'my precious commit'

you get the value after previously having called "git write-tree" , that has
a long notation 3725c9e313e5ae764b2451a8f3b1415bf67cf471
or
a short one 3725c
both can be used

Collapse
 
jonnius profile image
Evgenii •

to newbies dont forget to initialize git folder add
$ mkdir git-101
$ cd git-101
$ git init

Collapse
 
yyycc profile image
whyyy •

wow

Collapse
 
jonnius profile image
Evgenii • • Edited

for those who receives an error calling checkout
$ git checkout -b FIX
fatal: this operation must be run in a work tree

...be sure you are NOT IN the .git subfolder