Skip to content

Instantly share code, notes, and snippets.

@mitbailey
Last active August 9, 2023 16:29
Show Gist options
  • Save mitbailey/6ba55e77916e4ca1ebdff4d971e76f51 to your computer and use it in GitHub Desktop.
Save mitbailey/6ba55e77916e4ca1ebdff4d971e76f51 to your computer and use it in GitHub Desktop.

Git Reference


Custom File Explorer open Command from WSL2

echo 'alias open="explorer.exe"' >> ~/.bashrc
source ~/.bashrc

Now run:

open .

Generate SSH Key

ssh-keygen -t rsa -b 4096 -C "youremail@host.com"
cat ~/.ssh/id_rsa.pub

Then copy and paste into GitHub settings, SSH and GPG keys.


New Repo

git init  
git add .   
git commit -am"Initial commit."   
git branch -M master   
git remote add origin git@github.com:username/repo   
git push -u origin master   

Move a Repo

git clone --mirror <original_repository>
git remote rm origin
git remote add origin <new_blank_repo>
git push origin --all  
git push --tags  

Tags

Simple

git tag v0.1-alpha

Annotated

git tag -a v0.1-alpha -m "Version 0.1 Alpha"

Push

git push origin v0.1-alpha

Checkout

git checkout v0.1-alpha


Branches

New Empty Branch

git checkout --orphan branch_name
git rm -rf .
git commit --allow-empty -m "Root commit."
git push origin branch_name

Submodules

Adding

git submodule add git@github.com:username/submodule

Initializing (First Time Setup)

git submodule update --init --recursive

Updating

cd <submodule_directory>  
git pull origin master  

Removal

git rm <path_to_submodule>

Note: This will keep the .git reference to allow checking out old commits. To remove this, follow the additional steps below:

rm -rf .git/modules/<path_to_submodule>
git config --remove-section submodule.<path_to_submodule>

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