||||||||||||||||||||||||||||||||||||||||||||||||||
Installation
- Install Git
Verify Installation
Don’t know if git installed successfully or not?
- Verify if Git is installed, by using the following command in the Git Bash Terminal :
This Command will return the version of git in floating digits which verifies that Git has been installed successfully
git --version
Get started with Git
Don’t know where to start?, Check this easy stepwise guide below:
1. Create a New Folder
mkdir Folder
This command will create a new folder named
Folder
in your Current Directory(cd)
2. Initialise Git
cd Folder/ git init
This command will create a new
hidden
folder inside yourFolder
3. Create
Readme.md
file
cat > Readme.md
This command will create a new
Markdown
file namelyReadme.md
insideFolder
Hello World!
Type above text or any other Markdown Text inside
Readme.md
file
press ctrl+c
Press Ctrl+c to
save & exit
theReadme.md
file4. Staging
git add .
Use this command for
staging
all
the files
Or
git add Readme.md
Use the following command for
staging
theReadme.md
file5. Committing
git commit -m "My First Commit"
Use this command to
commit
theReadme.md
file with themessage
as"My First Commit"
. Use relevant messages while committing6. Remote Repository
Here we will be using
GitHub
for theremote repository
- Go to Github
- Create a
new Repository
by clicking on either of these 2 buttons shown below:- After this it will redirect to a
new Repository form
, Fill theName
of the repository you want to give to your very first Repository(e.g. Understanding-git)
- Once the Repository is created, you will be able to see a page somewhat similar to the following screenshot :
- In this
Screenshot
, the highlightedGreen Line
is theRepository URL
Copy
theRepository URL
and add in the below command to add theremote to origin
git remote add origin [Repository URL]
7. Git Push
git push -u origin master
This Command will
push
all the code from thelocal repository
into theremote repository
Additional Commands:
Some more commands to help you manage with your
version control
journey:Git Pull
git pull origin master
This command will
pull
thelatest changes
from theremote repository
into thelocal repository
. The remote repository code is updated continuously by various developers, hence git pull is necessaryGit Clone
git clone [repository url]
This command is used to
clone
anexisting remote repository
into your computerGit Status
git status
This command find out
information
regarding whatfiles are modified
and whatfiles are there in the staging area
Git Log
git log
This command will
print out all the commits
which have been done up until nowNew Branch
git branch [Branch Name]
This command creates the
Branch
named as[Branch Name]
Git Checkout
git checkout [Branch Name]
This command will
switch(checkout)
current branch
to[Branch Name]
||||||||||||||||||||||||||||||||||||||||||||||||||
CONGRATULATIONS
¯\_(ツ)_/¯
Now you know the basics of how to use Git.