Skip to content

Latest commit

 

History

History
128 lines (82 loc) · 1.88 KB

Git Command.md

File metadata and controls

128 lines (82 loc) · 1.88 KB

Git Comand To Be Used!

Clone any Repository

  • In place of <GitHub Repository> add the GitHub Repository's URL
git clone <GitHub Repository>

Initialise Git

git init -b main

add a file

  • In place of <file name> add the file name
git add <file name>

add all files

git add .

To view the status

git status

To commit

  • -m is for writing the commit in the command line itself
git commit -m " descriptive commit message"

Add remote

  • origin is like a place holder for the <Address of the repository(.git)>
git remote add origin <Address of the repository(.git)>

Check remote

git remote

check remote url

git remote -v

push the repo

  • push your commits on branch <branch name>
git push -u origin <branch name>

See Log

git log

Create Another Branch

  • Create a new branch with name <new branch name>
git branch <new branch name>

Change Branch

  • Jump from the current branch to another branch <branch name>
git checkout <branch name>

Unstage a File

  • unstage a file name while retaining the changes in working directory
git reset <file name>

Merge

  • merge the specified <branch name> history into the current one
git merge <branch name>

Fetch

  • fetch down all the branches from that Git remote
  • <alias> == origin
git fetch <alias>

Pull

  • fetch and merge any commits from the tracking remote <branch name>
git merge <branch name>

For More Commands and Details: GitHub Cheat Sheet