the ultimate guide to Git: learn everything you need in less than 1 hour

the ultimate guide to Git: learn everything you need in less than 1 hour

Last Updated on Nov 28, 2022

Here is everything you need to know about git in a series of short question and answers.

Q: What is git?

Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.

Q: Where can I download it?

you can download it from https://git-scm.com/

you can install it on mac, windows, linux. there is no limittion

Q: How can I initialize git in my project?

in your project folder run this command:

git init

Q: How can I see which files have been Added, Deleted or Updated?

you can see the status of all the files by running this command:

git status

Everything is untracked or changed

Untracked: it’s not added to git for version control (new files)

Changed: it’s been updated

Q: How can I add untracked or changed files?

you can run the command

git add <file-name>

or if you want to add everything, run this command:

git add .

after this you need to commit in order to have your changes stored in the local repository

Q: what is a repository?

A repository (repo) is nothing but a collection of files and source codes.

Q: what if I realized I don’t want the changes and I don’t want to commit them?

I recommend you to watch this video for detailed explanation

https://youtu.be/gv6qSY0Hv1s

 

Q: how can I commit the changes and store them in the local repository?

you can run the command

git commit -m "message you want to write for these changes"

Q: How can I see the history (logs) of my commits?

you can see them by running

git log

Q: how can I go back to a previous commit?

after you run

git log

it gives you an address (hash) for each commit by running the following command on your local repository you can go back to that specific head

git reset --(soft or hard) HEAD

more details:

https://devconnected.com/how-to-git-reset-to-head/

Q: what are branches and how can I work with them?

branches are like parallel timelines. it’s like going to another timeline to change something and if it was good you’d merge that to the current timeline.

to learn about git branch workflow you can watch this:

https://youtu.be/osNp79ew8f8

 

Q: what if I made a mistake and I want to remove the merged branch (timeline) from the master branch (current timeline)?

don’t worry. you can go back to the history when your timelines were not merged yet. if you want to learn more watch this:

https://youtu.be/qa2aTaMul8E

 

Q: some of the names and tasks are too hard to remember Or too long and I want to use another name or make the shorter. can I do that?

of course. you can make Aliases (shortcuts) for them.

if you want to learn how to do that you can watch this:

https://youtu.be/bUCIVgfs30o

 

Q: what are GitHub and GitLab?

everything you did so far was on your local computer. GitHub and GitLab are like the online git. when your repository is online it’s easier to work as a team and contribute to different projects.

Q: how can I interact with my online repository (project)?

it’s actually very easy. you can learn it by watching this:

https://youtu.be/K6THyJKayFo

 

Q: how can I contribute to other people’s repositories (projects)?

Now that you are ready to contribute, you can learn it by watching this video:

 

https://youtu.be/NdAaCcLrSmM

 

Resources:

Conclusion

Now you are able to find your way around git. You can add it to your list of skills.

I recommend you practice by creating a new repository Or find a project you like on GitHub and start contributing to open source projects.

If you have any suggestions, questions, or opinion, please leave a comment below. I’m looking forward to hearing from you!

Key Takeaways

  • initialize a git repository
  • add your files and get the status of all the files in your repository
  • commit your changes
  • see the log of your commits
  • interact with an online git repository
  • contribute to open source projects

Category: programming

Tags: #git

Join the Newsletter

Subscribe to get my latest content by email.

I won't send you spam. Unsubscribe at any time.

Related Posts

Courses