cheat sheet for git
git
# list users information
git config --list
# set user name and email
git config --global user.name ted
git config --global user.email "your_email@xxx.com"
submodules in git
# cloning rep that contain submodules
git clone --recursive url_rep
# if already have cloned a rep, now want to load its submodules
git submodule update --init
# if there are nested submodules
git submodule update --init --recursive
# download up to 8 submodules at once
git submodule update --init --recursive --jobs 8
# creat a git repo
# add submodule
git submodule add <url> <path>
ssh key
- how to generate ssh key for more info.
# ssh key resides in .ssh folder
ls ~/.ssh
# id_rsa is private key, id_rsa.pub is the public one.
# gen new ssh key
ssh-keygen -t rsa -C "your_email@example.com"
# the "email@example.com" is just for comment, anything else can put here.
- git ssh key
add ssh key to git server
profile and settings ==> SSH GPG Keys
git ignore
- git-ignore-tuts
- gitignore-collections
- gitignore.io-ignore-files-search-engine
- create a global ignore file.
git config --global core.excludesfile ~/.gitignore_global
- automatically-create-gitignore
git submodule
- git-submodule-tutorial
git submodule sync
git managing branches
# create new branch
git checkout -b dev
git branch # check branches
# merging branch
git merge dev
# delete branch
git branch -d dev
git cooperation for a team
- basics
git remote
git remote -v
git push origin master
git push origin dev
- example
git branch
git push origin dev
git push --set-upstream origin dev
git pull origin master
- branch
# 1. create a remote branch
# https://stackoverflow.com/questions/1519006/how-do-you-create-a-remote-git-branch/
git push <remote-name> <branch-name>
git push <remote-name> <local-branch-name>:<remote-branch-name>