Managing Remotes

Add a named remote (you can have multiple remotes):

git remote add github

git remote add gitlab

git push github
git push gitlab

Overloading origin with another remote:

git remote set-url ––add origin

Deleting a remote:

git remote remove origin


Creating submodules in an existing repo:

git submodule add

Cloning a repository with submodules:

git clone
git submodule init
git sumbodule update

Staging and Commits

Remove a file or folder from the staging area:

git reset HEAD -- <file or folder>


Deleting a local branch:

git branch -d branch_name

Deleting a remote branch:

push --delete remote_name branch

Checkout specific files from another branch:

git checkout branch_name file file2

Update a single file from upstream:

git checkout origin/master --  file

Merge a specific commit to current branch:

git cherry-pick 63344f2

Hide branch changes:

git stash

Restore branch changes:

git stash apply