Skip to content

Instantly share code, notes, and snippets.

@tesuji
Last active April 17, 2018 15:33
Show Gist options
  • Save tesuji/877afe1ad734bae6d673e88f787fa76e to your computer and use it in GitHub Desktop.
Save tesuji/877afe1ad734bae6d673e88f787fa76e to your computer and use it in GitHub Desktop.
git default

We recommend every repository include a README, LICENSE, and .gitignore

Git global setup

git config --global user.name "username"
git config --global user.email "[email protected]"

New repository

git clone [email protected]:user/repository_dir.git && cd repository_dir
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master

Existing folder

cd existing_folder
git init
git remote add origin [email protected]:user/repository_dir.git
git add .
git commit -m "Initial commit"
git push -u origin master

Existing Git repository

cd existing_repo
git remote rename origin old-origin
git remote add origin [email protected]:user/repository_dir.git
git fetch origin master
git merge origin/master
git push -u origin --all
git push -u origin --tags

Never use git pull, use git fetch and git merge instead

git branch -avv # display all branch including remote/origin

Better, use git pull --rebase

Indent: tab -> spaces

find . -not -path '*/.git/*' -type f -name '*.cs' -exec bash -c 'expand -i -t 4 "$0" > /tmp/e && mv /tmp/e "$0"' {} \;

or

find . -type d -name '.git' -prune -o -type f -name '*.cs' -exec bash -c 'expand -i -t 4 "$0" > /tmp/e && mv /tmp/e "$0"' {} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment