Skip to content

Instantly share code, notes, and snippets.

@AmmarHaddadi
Created November 14, 2022 12:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AmmarHaddadi/51f25e74cc4b6e9f557d2572736b5eb1 to your computer and use it in GitHub Desktop.
Save AmmarHaddadi/51f25e74cc4b6e9f557d2572736b5eb1 to your computer and use it in GitHub Desktop.
git 101

Download Git @ https://git-scm.com/downloads , or sudo pacman -S git for arch based distros

Before you Start

Give your commits a signature / credits

$ git config --global user.name "John Doe"
$ git config --global user.email johndoe@example.com

local repo

git init to initialize git inside your current directory
git add to track a file
git add . to track all files in directory
git rm --cached <file name> to untrack a file
git commit to commit the added/staged files\

  • -m "<message here>"
  • -m "<message here>" -m "<description here>" enter image description here git commit -am to commit files that you tracked before (no need to git add them)
    git status to see which files are (un)tracked or modified
    git checkout <branch name> to change the current branch

remote repo

git clone <repo link> to clone a remote repo to your local machine inside the current directory

link your branch to a remote repo

unlink your branch from a remote repo

git <branch> --unset-upstream

To save your GitHub / Git Lab credentials

> git config credential.helper store
> git push https://example.com/repo.git
Username: <type your username>
Password: <type your password/token> 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment