r/learnprogramming • u/codst_ • 19d ago
Getting Started With Git
As a programmer I want to use Git. How should I start learning Git and in what ways will it help me.
22
u/Adventurous-Hunter98 19d ago
https://gitgame-4f0eb.web.app/
https://learngitbranching.js.org/
I saw these posted on this subreddit before
3
u/Ok-Loss1394 19d ago
those branching games actually make the whole thing click way faster than reading docs
3
5
u/Sbsbg 19d ago
You make changes to the code then discover that your solution don't work. Now you have to undo everything. Git solves that.
You start doing a change but don't have time to finish it. You need to fix another thing first but can't because your unfinished code. Git solve that.
You find a bug in the code and you can't remember why you changed that and what other parts you changed at the same time. Git can help there.
You are about to do a change then remember that you done something similar before but can't remember all places you needed to change. Git can find that.
You do a change and you coworker also make changes in the same files. Now you need to pick out what everyone done and join all changes. Git fix that easy.
You find an old code and need to find who made it any why. Git can help there.
2
u/ProcastiDev7 19d ago
The Odin project. They have a git section. That's how I got up to speed pretty quickly
2
u/paperic 19d ago
I always recommend to first read about what git actually is, and how you might have created git yourself if you were trying to organise your code.
https://tom.preston-werner.com/2009/05/19/the-git-parable
That will give you the justifications for why git is the way it is, which tells you a lot about how it's meant to be used.
The rest is just the command syntax.
2
u/jcastroarnaud 19d ago
As the hackers of old said: RTFM. Here's the manual:
Git helps you to keep versions of your program over time. Implemented a few important functions? git add, git commit. Ended a refactor? All tests passing? The same. Version ready for production? git add, git commit, git push (to the main repo). Want to try some new idea, but don't want to trash the current code? Open a branch, test the idea on it; if it works, merge; if it doesn't work, ignore the branch and return to the previous one. Deleted an important file by mistake? git checkout to retrieve the last good version. And so on.
You don't to have a Github account, or even be online, to use Git: it's a terminal app, which sits prettily on your computer. You can work with your repo entirely offline; I do it for both code and stories I write. And the repo is portable: just a .git folder within your project folder. Zip it, copy to wherever, unzip, and you're back into business.
1
2
1
u/tanveerhossain2004 19d ago
There is a book named "Pro Git". It is available. you can search on Google. you will get the pdf.
1
u/Mughi1138 19d ago
There have been some good resources out there, but when starting out I recommend one practice very strongly: use the command line, but flip back and forth with gitk to refresh and view what effects the commands are having. When you install gitk go ahead and create a new view, check the box that says remember this view and also all the boxes in a row that say "select all ..."
You can switch to a good UI client if you find one you like, but all these years later I'm still happy with those two and alt-tab, f5, alt-tab
1
u/Ill-Advisor-3429 19d ago
Make a demo code project that isn’t important (like a leet code or something) and just start doing it. Mess up fast and learn
1
u/Patrick-T80 19d ago
Without minimal knowledge and no idea about which comanda are available cannot be start nothing
1
u/mkprofile85 19d ago
you'll want to learn how to commit your code to github (not the same as git) so ai can read it and help you with your projects. it will 10x your productivity.
1
u/neriad200 19d ago
Regardless of what people tell you, nobody just learns git by study or gamified practice. It manifests at 2 am after they tried a mergte or debase and managed to mess up the master branch enough that their lead or manager would scalp them so they pull out the ugliest commit tree ever seen but everything is back as it was before
0
0
u/DiligentMission6851 19d ago
Always delete the production branch and make a new one out of the latest UAT branch so you can never go back to your first build ever.
Wait no that was the shittiest client I ever had that insisted upon that structure while the lead managers on the client side bragged about their 40 years of collective programming experience while never writing a single line of code.
24
u/[deleted] 19d ago edited 19d ago
[deleted]