Skip to content

Instantly share code, notes, and snippets.

@Monmoy042
Last active September 6, 2021 15:26
Show Gist options
  • Save Monmoy042/692efe168b8416b6bcc278fe4b53dcd6 to your computer and use it in GitHub Desktop.
Save Monmoy042/692efe168b8416b6bcc278fe4b53dcd6 to your computer and use it in GitHub Desktop.

Git Basic Commands


Git version check

$ git --version

User Name and Email Setting

$ git config --global user.email "email@example.com"
$ git config --global user.name "Mona Lisa"

Verify Username and Email

$ git config --list
$ git config --global user.email
$ git config --global user.name

Check Git Log and Status

$ git status
$ git log
$ git log --oneline

Upload files and folders on GitHub

$ git init
$ git add .
$ git commit -m "Commit messages write here"
$ git branch -M main
$ git remote add origin [Repository link]
$ git push -u origin main

Git Branch

$ git branch (For showing branches)
$ git branch --list
$ git branch [branch name] (Create a new branch)
$ Example: git branch newBranch
$ git checkout [branch name]
$ Example: git checkout newBranch
$ git checkout -b [branch name] (Create a new branch and checkout that branch)
$ Example: git checkout -b newBranch2
$ git merge [branch name]
$ Example: git merge newBranch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment