What is Git? Why are we using it?
Git is a version control system that developers use all over the world. It is downloaded on your computer.
If you are working on a project, say developing a website, you are writing all the source code (HTML, CSS, javascript) and you want to save or record every small change you make, git comes in. You can have a record of all the changes you made with time. Or if you want to collaborate with your friends and want to know who made this change and at what time, in your source code, git comes in.
What is a Version control system?
It is a software tool that helps in recording changes made to files by keeping track of modifications done in the code.
What is GitHub?
(Complete guide to GitHub coming soon)
GitHub is a code hosting platform for version control and collaboration. It lets you and others work together on projects from anywhere. These are some of the alternatives of GitHub: GitLab, Bitbucket etc.
You can also store your code here, just like Google Photos. But every change you make will be recorded.
Finally, Git Commands ๐ช
git --version: Tells you which version of git you are using.
git --help: synopsis and a list of the most commonly used commands
git init: initialising empty git repository( initialise this in the folder in which you want to record the changes)
git status: It shows you which files have been modified, added, or deleted, as well as the branch you're on and whether there are changes that need to be committed.
git add <filename>: adding the untracked file by name.
git add. : add all untracked files in the current directory.
git commit -m "commit message": Commit the staged snapshot.
git log: Time travel through commits. It shows all the commits you made.
git remote add origin <repos URL here>: here remote means we are working with URLs and add means adding a URL. Origin is the name of the URL. You are going to push your changes into the repo by this link.
git switch -c <new-branch-name>: switching to a new branch from main branch.
git push origin main: pushing the changes to origin URL into main branch.
git remote set-url origin <new-url>: if you wanted to update the URL of the remote named "origin" to a new URL.
Conclusion
Git is like a super tool for developers, helping them keep track of changes in their work. If you're building stuff, Git saves every little change you make, even when working with friends. Think of it as a history book for your code. GitHub is like a safe place where you can store your code, and it's like Google Drive for code (just for understanding) but also for remembering all the changes you've ever made.