DEV Community

Cover image for The guide to Git I never had.

The guide to Git I never had.

Jake Page on April 10, 2024

🩺 Doctors have stethoscopes. πŸ”§ Mechanics have spanners. πŸ‘¨β€πŸ’» We developers, have Git. Have you noticed that Git is so integral to working with code...
Collapse
 
karadza profile image
Juraj

I like a clean commit history, interactive rebasing was a real find for me!

Collapse
 
danhof profile image
Daniel Hofman

Great post! The section on common Git commands resonated with me. CommandGit app builds on this foundation by letting users execute these commands in batches, making complex workflows simpler without hiding the command line magic.

Collapse
 
ccoveille profile image
Christophe Colombier

Good article, as audience for such article is intended for git newcomers. I would have suggest to use --force-with-lease in your example instead of --force and explain the differences.

Collapse
 
jakepage91 profile image
Jake Page

That does actually make sense I will update the article shortly! Thanks for pointing that out

Collapse
 
ccoveille profile image
Christophe Colombier
Collapse
 
stevepotter profile image
Stephen Potter

I have used git extensively throughout the majority of my 23 year career. One thing I tell newcomers is to not be afraid of the command line, but don’t feel inadequate if you use guis. GitHub desktop is a great application, especially for viewing commit contents and diffs. I use it every day along with the command line. Try it out. I also ask newcomers to make a PR on their first or second day, even just a readme fix, so they understand the process

Collapse
 
awenath profile image
Awenath • Edited

Great post ! I would add that you can make your life easier when conflicts happen with git mergetool, which can be configured to your favorite file comparator. I personnaly use p4merge that I find quite clear to use πŸ˜‰

Collapse
 
jakepage91 profile image
Jake Page

super cool @awenath I was unaware of those tool. Will check them out for sure

Collapse
 
yogini16 profile image
yogini16

Wonderful contribution! I found the part about familiar Git commands particularly impactful. The CommandGit application enhances this concept by enabling users to perform these commands in groups, streamlining intricate processes while still preserving the essence of command line mastery.

Collapse
 
rohiitbagal profile image
Rohit

Awesome....very interesting and knowledgeable topics all you are mentioned

Collapse
 
vincanger profile image
vincanger

How did I git anything done before without this?

Collapse
 
jakepage91 profile image
Jake Page

badumdum

Collapse
 
supermari0s profile image
ΞœΞ¬ΟΞΉΞΏΟ‚

Great post ! I had to look what's the difference between git switch and git checkout πŸ‘€πŸ˜

Collapse
 
matijasos profile image
Matija Sosic

Good stuff! I'm using git every day, but there is always something new you can learn. This is a nice cheat sheet to keep close.

Collapse
 
nevodavid profile image
Nevo David

This is awesome!

Collapse
 
tungbq profile image
Tung Leo

Nice article! Thanks

Collapse
 
neatshell profile image
Claudio Stella

For the Peter's gif alone, worth the post the save for later

Collapse
 
scottgoettepnc profile image
scottgoettepnc

Excellent post!!

Collapse
 
ppaanngggg profile image
ppaanngggg

Thanks, clear figures showing how git works

Collapse
 
jroycodes profile image
Jonathan R. Mugisha

I see myself coming back to this.

Collapse
 
russellbateman profile image
Russell Bateman

Nice illustrations, especially the one just under "Getting Started with Git".

Collapse
 
jakepage91 profile image
Jake Page

hahah that the only one that is not mine, the original creator of the image has been linked to the image.

Collapse
 
maxwell_mitchell profile image
Maxwell Mitchell

Awesome , great information

Collapse
 
parmcoder profile image
Possawat Sanorkam

Good job!

Collapse
 
mezieb profile image
Okoro chimezie bright

thanks for sharing

Collapse
 
trillastrobuzz profile image
Trill Astro Buzz

Thank you.
Skill learned: Rebase

Collapse
 
shohams profile image
Shani Shoham

Super helpful!

Collapse
 
amandasimno profile image
AmandaSimno

This guide has the potential to be incredibly valuable, providing clarity and insights to others who may be in a similar position. gold365

Collapse
 
fretny profile image
fretny

nothing good like a clean commit history

Collapse
 
rinaldgarcia profile image
RinaldGarcia

The ultimate roadmap for mastering Git - wish I had this from day one! Lotus 365 In

Collapse
 
django-webdev profile image
Django Web Dev

The best GIT write up ever!!!

Collapse
 
qyrusai profile image
Qyrus

You git it! Great read! Informative, humorous, and well written. Thanks for sharing!

Collapse
 
jakepage91 profile image
Jake Page

Much appreciated @qyrusai !

Collapse
 
captaingenesisx profile image
CaptainGenesisX • Edited

Hello. Thank you for publishing this great article! I am still working on reading through the guide but wanted to bring something to your attention. I am using Visual Studio 2022 and my Git is already connected to a repo with my own branch that has unstaged changes. I followed some of your sample commands in the "working with branches" section such as this:

# Will show the changes in the local repository
git branch

However, for me, doing git branch does not show the changes in the local repo. It simply shows me the branches available on my local machine (master, and pbi/123456).

Doing git status is what shows me the changes in my branch. Not sure if I am just misunderstanding or if your comment needs modified. I mean no disrespect and I appreciate your content!

Collapse
 
jakepage91 profile image
Jake Page

You are right yeah, git status is what you run to see the status of the progression of your workflow, for example if the output is red, the unstaged changes have been detected, if the output is green/yellow (sorry I'm color blind and have an issue with those two) the changes have been stages (with git add ) and ready to committed.

Git branches is only for viewing the available local branches. Sorry if that wasn't clear.

Collapse
 
bcouetil profile image
Benoit COUETIL πŸ’«

Thank you for sharing, nice work for newbies πŸ‘

You differentiate feature branch mode and PR mode, but they are the same from a git workflow perspective (or you did not explain how they are different).

And trunk-based-development is rarely commiting directly to trunk.

Keep up the good work 😊

Collapse
 
jakepage91 profile image
Jake Page

Hey @bcouetil you are right to bring the similarity of both branching workflows in the article. Initially I included the PR workflow as well as the Feature branch work flow, because I read elsewhere that some smaller team with more liberal merging practices would merge without a PR. But to be honest since this is not an common ocurrance I think it makes sense to remove the PR workflow and explain that Feature branching merges by raising PRs. Cheers!

Collapse
 
rodkey profile image
John Rodkey

Great explanation. The only change I'd make is to ditch the credential.helper section and replace it with the equivalent for ssh key. Nice to know about the different philosophies of branch management (Git Workflows). I typically use Pull Request workflow.

Collapse
 
jakepage91 profile image
Jake Page

Thanks for that @rodkey makes sense. ssh is best practice for sure. Will update over weekend. Thanks for the input

Collapse
 
fernandezbaptiste profile image
Bap

I wish I had this in the past... πŸ˜„

Collapse
 
harryadney profile image
Martin Dimmock

That Peter Griffin reference is sooo appropriate for how I feel about GIT. Thank you for an excellent overview of GIT, it helped me a lot.

Collapse
 
tyaga001 profile image
Ankur Tyagi

Nice blog @jakepage91 πŸ‘Š

Collapse
 
jakepage91 profile image
Jake Page

Cheers Ankur!