Let's start with what is Git and GitHub.
To understand GitHub, you must first have an understanding of Git.
Git is an open-source version control system that was started by Linus Torvalds- the same person who created Linux. Git is Similar to version control systems- CVS, Subversion and Mercurial to name a few.
So, Git is a version control system, but what does that mean? When developer create something (an app, for example), they make constant change to the code, releasing new versions up to and after the first official (non-beta) release.
and, GitHub is a code hosting platform for collaboration and version control. GitHub lets you (and others) work together on projects.
Here is the 7 basic git commands for beginners
1. git init
- It turns a normal folder on your computer into an empty git repository.
- This is very first step for creating a git repository.
2. git clone
- This command creates a local working copy of an existing "remote repository" you can use this command to copy or download the repository on your local machine.
Syntax : git clone <remote-url>
Example : git clone https://github.com/tushar821999/Covid-19-Tracker.git
3. git add
- This command add files to the staging area.
so, what does staging area means ?
The working area is where files that are not handled by git. These files are also referred to as "untracked files." Staging area is files that are going to be a part of the next commit, which lets git know what changes in the file are going to occur for the next commit.
Syntax : git add <file or dir name>
Example (to add all files) : git add .
Example (to add a file) : git add "index.html"
Example (to add a dir) : git add scripts
4. git status
- If a file is in the staging area, but not committed, it shows with git status or, if there is no changes it will return nothing to commit, working directory clean.
Syntax : git status
5. git commit
- This command creates a commit which is like a snapshot or you can say a save point of repo.
Syntax : git commit -m "log commit message here"
Example : git commit -m "Add Sum Logic"
6. git branch
- By this command you can add a new branch to your master branch or any existing branch with this command
Create : git branch <branch name>
Example (create) : git branch Apr-Rel-2021/Apr-Rel-2021
List all branch : git branch -a
Delete : git branch -d <branch name>
Example (Delete) : git branch Apr-Rel-2021/Apr-Rel-2021
7. git checkout
- To start working on different branch, use this command to switch branches
Checkout / Switch : git checkout <branch name>
Example (checkout / switch) : git checkout Apr-Rel-2021/Apr-Rel-2021
Create branch and checkout : git checkout -b <new branch name>
Example (create & checkout : git checkout -b May-Rel-2021/May-Rel-2021
If you made it till here and find this useful give a follow up (+1) to me
Checkout my twitter handle : tshrvrm