Skip to content

Instantly share code, notes, and snippets.

@Jakiboy
Created April 4, 2023 20:44
Show Gist options
  • Save Jakiboy/2381f930b271473e34651a4befe9a2e0 to your computer and use it in GitHub Desktop.
Save Jakiboy/2381f930b271473e34651a4befe9a2e0 to your computer and use it in GitHub Desktop.
GIT (Documentation)

GIT (Documentation)

Configuration

git config --global user.name "{username}"
git config --global user.email "{email}"
git config --global core.ignorecase false
git config --global core.editor {subl}
git config --global merge.tool {filemerge}
git config --list

Global

Help

git help config
git help push
git help pull
git help branch

Status

git status

List branchs

git branch -a

* Current branch.

Create branch

git branch {branch-name}
git checkout {branch-name}

git checkout -b {branch-name} # With switch

Remove branch

git branch -d {branch-name}

git push origin --delete {branch-name}

Change branch

git checkout {branch-name}

First commit

git add .
git commit -m "initial commit"

Next commit

git add {file}
git commit -m "added file"

Cancel last commit

git reset --hard {commit}
git push --force

Update local

git pull
git pull origin {branch-name} # Specific

Send commits

git push
git push origin {branch-name} # Specific

Remove file from work dir

git rm {file}

Remove file from index

git rmg --cached {file}

Diff

git diff HEAD

git diff A B

git diff master..{branch} {path}

Log

git log

git log -n {x}

git log --oneline -- {path}

git log --since=date --until=date

git log --oneline --graph --decorate

git log --oneline --graph --decorate {file}

Cancel commits

git reset HEAD # Last
git reset HEAD -- {file} # Cancel file
git reset dsq1234 # Cancel with ID
git reset --hard HEAD^ # Cancel with Hard
  • HEAD
  • HEAD^
  • HEAD^^
  • HEAD~2

Github

Create

git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/{user}/{depot}.git
git push -u origin main

Push

git remote add origin https://github.com/{user}/{depot}.git
git branch -M main
git push -u origin main

Authors:

  • Jihad Sinnaour - Jakiboy (Initial work)

⭐ Support:

Please give it a Star if you like the project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment