DEV Community 👩‍💻👨‍💻

Avinash Vagh
Avinash Vagh

Posted on

Beginner guide to GIT and mastering the Terminal

Hey guys,
Here I will list down all the Basic GIT operation command and basic Terminal command. I'm sure it will helps you.

Create a Repository

create a new local repository

git init project_name
Enter fullscreen mode Exit fullscreen mode

download the existing repository

git clone github_repo_url
Enter fullscreen mode Exit fullscreen mode

Observe Repository

list a new or modified files not commited

git status
Enter fullscreen mode Exit fullscreen mode

show full change history

git log
Enter fullscreen mode Exit fullscreen mode

Branches

list all local branches

git branch
Enter fullscreen mode Exit fullscreen mode

list all local and remote branches

git branch repo_name
Enter fullscreen mode Exit fullscreen mode

switch to branch

git checkout my_branch
Enter fullscreen mode Exit fullscreen mode

create a new local branch

git branch new_branch
Enter fullscreen mode Exit fullscreen mode

delete a branch

git branch -d my_branch
Enter fullscreen mode Exit fullscreen mode

Making Changes

stage a file (ready for commit)

git add file_name
Enter fullscreen mode Exit fullscreen mode

stage all changed files

git add .
Enter fullscreen mode Exit fullscreen mode

commit all staged files

git commit -m "some comment"
Enter fullscreen mode Exit fullscreen mode

change last commit

git commit --amend
Enter fullscreen mode Exit fullscreen mode

unstage file. keeping file changes.

git reset file_name
Enter fullscreen mode Exit fullscreen mode

Synchronize

get all updates(branches) from remote repository

git fetch --all
Enter fullscreen mode Exit fullscreen mode

updates current branch with remote branch changes

git pull origin branch_name
Enter fullscreen mode Exit fullscreen mode

updates remote branch with local changes

git push origin branch_name
Enter fullscreen mode Exit fullscreen mode

Basics steps of working with GIT


1. git clone remote_repository_url
2. git add .
3. git commit -m "comment"
4. git push origin master

// this steps are basically mostly used 
Enter fullscreen mode Exit fullscreen mode

TERMINAL COMMAND

There are 5 types of terminal basically.

  • Git Bash
  • Command Prompt
  • PowerShell
  • JavaScript debug terminal
  • zsh

Here I will list down all basic command you need to work with the terminal

ls

// list all your home directory
Enter fullscreen mode Exit fullscreen mode
pwd

// show you where you're in home directory.It will show the exact path
Enter fullscreen mode Exit fullscreen mode
cd folder_name/location_name/desktop

// for changing directory
Enter fullscreen mode Exit fullscreen mode
clear

// for clearing everything in terminal
Enter fullscreen mode Exit fullscreen mode
cd ..

// it will go back one directory
Enter fullscreen mode Exit fullscreen mode
cd/users/your_pc_user_name/project

// if you directly want to go into some directory they you can use it like this command
Enter fullscreen mode Exit fullscreen mode
cd /

// it will take you to root directory
Enter fullscreen mode Exit fullscreen mode
mkdir folder_name

// make a directory
Enter fullscreen mode Exit fullscreen mode
mkdir folder1 folder2

// two folder at a time you can create in one go
Enter fullscreen mode Exit fullscreen mode
man ls

// list directory content
Enter fullscreen mode Exit fullscreen mode
ls -l

// it will show directory created/updated time
Enter fullscreen mode Exit fullscreen mode
ls -l

// more information
Enter fullscreen mode Exit fullscreen mode
ls -a

// it will show hidden file
Enter fullscreen mode Exit fullscreen mode
ls -la

// both command at the same time & you've to write dash only once 
Enter fullscreen mode Exit fullscreen mode
touch file_name(file.txt/ file.html/file.css/file.js)

// create a file from command line
Enter fullscreen mode Exit fullscreen mode
touch file.hmtl file.css file.js

// create a three file at a time
Enter fullscreen mode Exit fullscreen mode
rm file.css

// it will remove the specific file
Enter fullscreen mode Exit fullscreen mode
rmdir folder_name

// remove only empty folder
Enter fullscreen mode Exit fullscreen mode
rm -rf folder_name

// it will remove folder with all content inside it
Enter fullscreen mode Exit fullscreen mode

That's it for now guys, see you in the next article.
If you like my blog, follow me for more updates. You can follow me on Twitter & can connect with me on LinkedIn, Meanwhile you can checkout my Hashnode Blog.

one line from series I'm watching:

"To Win, You Have To Attack" - Light Yagami (Deathnote)

Stay fit, Keep coding, Keep exploring & Be happy with what you do.

Top comments (0)

🌚 Friends don't let friends browse without dark mode.

Good news! You can update to dark mode in your DEV settings.