Git and GitHub (An Overview)
Introduction
Git was created by Linus Torvalds the legend of the Linux world in 2005. Git is software used to control different versions of your code, which is also called a Version Control System.
GitHub is just an online platform managed by Microsoft to manage your git repositories on the web.
Long story short, Git is used locally on the system and GitHub is used remotely on the web.
Git
Git is a version control system used locally on the system to manage your git repositories.
Installation and Configuration Of Git
Download from here: git-website
Installation
- Download for windows in the above-provided link.
- Once downloaded open the downloaded file and keep clicking next until installation is finished.
- When Git is installed you will see that the Git bash is also installed. Go to your apps and search for Git bash and open it.
Now from here onwards we will be configuring Git.
Configuration
Open your git bash and start writing the following commands
- First, you need to set your username and email using the following commands in the git bash terminal
git config --global user.name "Your name"
git config --global user.email "your-email@email.com"
2. Now, you can check if your username and email have been correctly configured using the following commands
git config --global user.name
git config --global user.email
Now, you’re all set to start learning how Git works!
Common Git Commands To Know
Files being tracked means that if you change anything in the tracked file, git will know that something has changed.
Changes in untracked files will not be noticed by git
- git init: When you want to make your repository a git repository you use the command “git init” when you’re in that repository, and this will make that repository a git repository.
- git status: The git status command checks if any file is untracked, tracked, or saved (committed).
- git add: The git add command starts tracking your untracked files.
- git commit: The git commit saves a snapshot of your code, so if in the future you want to go back to the previous version of your code you can easily go back to the saved snapshot of that version of your code.
- git remote add origin: This command is used to link your local repository to your remote repository(GitHub).
- git push origin master: It pushes the changes saved on your local system to the remote system(GitHub).
- git checkout: It moves to the other branch of the git repository.
- git log: This shows you a history of all your previous commits(snapshots).
GitHub
GitHub is a remote git repository management system on the web.
To use GitHub go to this link and sign up.
Once you’re signed up, in the top left corner you will see an icon to create a new repository. Once the repository is created you will be given instructions on how to connect your local repository to the remote repository.
Once linked start using git push to push your local code to your remote repository on the server.