Skip to content

Hyuk/git-commands

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 

Repository files navigation

Git Commands

First Setup

git init
git add .
git commit -m "some comment"
git branch -M main
git remote add origin https://github.repository.address.git
git push -u origin main

Version Check

$ git --version

Initialize Local Git Repository

$ git init

User Name setup

$ git config --global user.name 'Hyuk'

User Email Setup

$ git config --global user.email 'hyukho83@gmail.com'

Check Status Of Working Tree

$ git status

Add Files to Index

$ git add <file>

Remove file from staged area #1

$ git restore --stage <file>

Remove file from staged area #2

$ git rm --cached <file>

Commit Changes In Index

$ git commit

Change name of the master branch to main

$ git branch -M main

Push to Remote Repository

$ git push

Pull Latest From Remote Repository

$ git pull

Clone Repository Into A New Directory

$ git clone repository-url

list out git settings

$ git config --list

check git remote url

$ git remote -v

Change git remote

$ git remote set-url origin https://github.com/user/new-git-repository.git

Rebase Setup

when you see git command error below, it will help fix the error

git error: failed to push some refs to 'master'

git pull --rebase origin master
git push origin master
git reset

git reset --hard <commit>
git reset --hard origin/master

remove uploaded files on github.

$ git rm --cached first_project/lib/home.dart
$ git commit -m "Fixed untracked files"
$ git push -u origin main

Check who and when made changes

$ git blame <file>

Check who and when made changes from line 1 to 10

$ git blame -L 1,10 <file>

Check who and when made changes from line 1 to 10 with long format

$ git blame -l <file>

Check commit history

$ git log

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published