paint-brush
Basic Git Commandsby@ysoni0303
407 reads
407 reads

Basic Git Commands

by Yash SoniJuly 21st, 2020
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Git is a distributed version control system for tracking changes in source code during software development while working on your local machine. GitHub is version-control distributed git platforms used for storing your code inside git repositories just like GitLab, BitBucket. The workFlow of Git & its commands: WorkFlow - Write some code > Commit changes > Make a pull request. Git’s workFlow is described as ‘WorkFlow’ and ‘commit’ by Yash Soni.
featured image - Basic Git Commands
Yash Soni HackerNoon profile picture

If you’re a Software developer, you cannot live without interacting with Git and it is never too late for anything!

So here are some very basic, yet very important Git commands which you will require in your daily life.

Git - Git is a distributed version control system for tracking changes in source code during software development while working on your local machine.

GitHub - Github is version-control distributed git platforms used for storing your code inside git repositories just like GitLab, BitBucket.

Let’s directly dive into commands & understand their usage:-

The workFlow of Git:

Write some code...

<p> Write some code... </p>

Store changes:

$git add .

Push changes:

$git push

Make a pull request:

$git pull

Commands for Git:

1. To check version

$git --version

2. Create a file in your project

$ touch index.html

3. Initialize it as a git repository

$git init

4. Add a file

$git add index.html
OR
$git add .  /*adds files modified*/

5. To see the status of a file

$git status

6. Remove index.html

$ git rm --cached index.hmtl

7. Commit changes

$git commit -m ‘messages’

8. Create a new branch

$git branch branchName

9. Change branch

$git checkout branchName

10. Merge branch

$git merge branchName

The workFlow of GitHub & its commands:

WorkFlow - Write some code > Commit changes > Make a pull request

Steps:
1. Create a new repository on your GitHub account
2. Copy the remote URL (https://github.com/ysoni0303/shopping-cart-angular8-node-mysql.git)
3. In your terminal write:
$ git remote

$ git remote

4. In your terminal write:

$git push -u origin master

Some Bonus Tips, as you read it till here…

i) read.md - Use this file to explain your project by writing a description of the same. Provide basic initial setup commands and also mention the languages & third party packages you used while developing certain applications.

ii) .gitignore - As the name suggests, it is a plain text file where each line contains a pattern for files/directories to ignore while pushing your code into the repository. Generally, this is placed in the root folder of the repository, and that’s what I recommend.

iii) git config - It is used to configure your username, email, and password, etc

git config --global user.name "userName" 
git config --global user.email "[email protected]"