Skip to content

Instantly share code, notes, and snippets.

@codayon
Last active August 1, 2025 15:15
Show Gist options
  • Save codayon/2d5df2c659ea9e39b75d4e19b48c3de9 to your computer and use it in GitHub Desktop.
Save codayon/2d5df2c659ea9e39b75d4e19b48c3de9 to your computer and use it in GitHub Desktop.

Git Essentials

Config User Globally

git config --global user.name "<username>"
# example
git config --global user.name "codayon"

Config Email Globally

git config --global user.email "<email>"
# example
git config --global user.email "[email protected]"

Initialize Git

git init

Add Remote Alias + Repo

git remote add <alias> <repo-url>
# example
git remote add origin [email protected]:codayon/dotfiles.git

Add Files To Commit

git add <file-location>
# example
git add src/ *json index.html

Add Everything To Commit

git commit -m "<message>"
# example
git commit -m "feat(lang): add bangla language"

Rename Branch

git branch -M <branch>
# example
git branch -M main

Push Commits To Branch

git push -u <alias> <branch>
# example
git push -u origin main

Reset Commit

git reset --soft HEAD~<number>
# example
git reset --soft HEAD~1

Force Push

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