How to use GIT

Are you new to git? Confused with all the commands and different keywords? Follow these steps, where I show you how to :
  • Download git
  • Configure git
  • Create Git repository
  • Create and Commit a file
  • Push to the Repo
01.Download git

You can download recommended version to your PC by using this URL:

02.Configure git

Verify successful installation by using the following command in command prompt:

git –version

 If you have successfully installed Git You should see output that looks something like:

git version 2.7.4 (your version)

That means you are good to go..!😉

03.Create Git Repository

You have to create a folder for your project in your computer. Lets assume the folder name is “car-git-demo”
Navigate to that folder from the Command prompt:

cd car-git-demo

Next, create a local git repository for the project using:

git init

04.Create and commit a file

You can add a file the git folder or create a new by using touch command:

touch index.html (File name)

Now, use git status to get the status of the working tree:

git status

Git will respond that nothing has been committed, but the directory does contain a new file. That means you have to commit your file.

But before committing you have to add files:

git add . / git add index.html

add . (will add all the files)/add index.html (only add specific file)

Finally, you have to commit changes:

git commit -m "Initial Commit" (any name)

You can use the “git status” to check status again after the commit and "git log" to view your commit history.

05. Push files to the Repository

To push all your work to your repository you can use this command:

git remote add origin yourLink

git push -u origin master

Comments

Popular posts from this blog

What is JavaScript?