Getting Started with git hub and git commands

In this article am going to take you through some basic git commands,you can use to produce different versions of your project Before we begin go through my git hub lesson here to set up your account well this is just but a simplified version of the basic git commands for the beginners,This is meant to build your basic knowledge when starting with git

Requirements:

  1. github account – create and login to your git hub account
  2. install git– install git on your computer
  3. Knowledge on using the command line

Create a new project in my case i have a very simple project here


<!DOCTYPE html>
<html>
<head>
    <title>git test</title>
</head>
<body>

    <h1 id="hello">hello </h1>

    <script type="text/javascript">

        document.getElementById('hello').innerHTML = "git lessons";



    </script>

</body>
</html>

Basic Git commands for begginers – in every

1 . Git Init

– used to initialize local git repository

to initialize the git repo in the root folder of your project

  • type the git init in the Command Line Interface on the root folder of your project

C:\Users\LENOVO\Desktop\git>git init
Initialized empty Git repository in C:/Users/LENOVO/Desktop/git/.git/

your git repo has now been initialized

2 . Git Status

– used to check the working tree status

to check on the files that exist on the root folder

  • type git status to check in my case i have index.html


C:\Users\LENOVO\Desktop\git>git status
On branch master

No commits yet

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        index.html

nothing added to commit but untracked files present (use "git add" to track)

3 . Git Add

– used to add files to the files

Now lets add the index.html file to the git repo

  • type git add . where the (.) – is used to add all the files present

see

C:\Users\LENOVO\Desktop\git>git add .

4 . Git Commit

– used to commit changes to the file

Now lets commit the index.html file we have to the repo

  • type git commit -m”your commit message”

C:\Users\LENOVO\Desktop\git>git commit -m"first commit"
[master (root-commit) 96f39f4] first commit
 1 file changed, 19 insertions(+)
 create mode 100644 index.html

5 . Git Push

– used to push to the remote repository.

In our case here our remote repository will be on git hub

Now we are going to push our project to git hub,

in your github account create a git hub repository and name it (any name of your choice )

to create a git hub repo follow the steps steps in this link

Now it time to push our project to git hub

  • first add remote url to the git repository
  • type git remote add origin “remote repository URL”

see


C:\Users\LENOVO\Desktop\git>git remote add origin https://github.com/ian-yitzhak/git-practice.git

Then push the changes to github repository

type git push origin master

see


C:\Users\LENOVO\Desktop\git>git push origin master
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Delta compression using up to 2 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 381 bytes | 54.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
remote:
remote: Create a pull request for 'master' on GitHub by visiting:
remote:      https://github.com/ian-yitzhak/git-practice/pull/new/master
remote:
To https://github.com/ian-yitzhak/git-practice.git
 * [new branch]      master -> master

your project in now live on github

6 . Git Clone

– used to clone repository into a new directory ,

It is used to download an existing repository

  • type git clone

see


C:\Users\LENOVO\Desktop\git>git clone https://github.com/ian-yitzhak/git-practice.git
Cloning into 'git-practice'...
remote: Enumerating objects: 9, done.
remote: Counting objects: 100% (9/9), done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 9 (delta 1), reused 3 (delta 0), pack-reused 0
Unpacking objects: 100% (9/9), 1.62 KiB | 1024 bytes/s, done.

NOTE: TRY adding more files and codes to your project and see the changes that will occur in the command line when you run the command/s above

 

Posted in
programming

Post a comment

Your email address will not be published.

As the top software development company in Kenya, we can't wait to show you what we can do. Our team of talented designers and developers are passionate about creating beautiful, functional websites that not only look great, but also help your business grow.
0

No products in the cart.

× Get Help?