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:
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:
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
or if you want to add everything, run this command:
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
Q: how can I commit the changes and store them in the local repository?
you can run the command
Q: How can I see the history (logs) of my commits?
you can see them by running
Q: how can I go back to a previous commit?
after you run
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
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:
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:
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:
Q: what are GitHub and GitLab?
Q: how can I interact with my online repository (project)?
it’s actually very easy. you can learn it by watching this:
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:
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!
- 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