Ted
7/22/2019 - 12:56 AM

git cheatsheet

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
  • working with submodules
# creat a git repo
# add submodule
git submodule add <url> <path>

ssh key

  1. 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.

  1. git ssh key

add ssh key to git server

profile and settings ==> SSH GPG Keys

git ignore

  1. git-ignore-tuts
  2. gitignore-collections
  3. gitignore.io-ignore-files-search-engine
  4. create a global ignore file.
git config --global core.excludesfile ~/.gitignore_global
  1. automatically-create-gitignore

git submodule

  1. git-submodule-tutorial
  2. 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

  1. basics
git remote
git remote -v
git push origin master
git push origin dev
  1. example
git branch
git push origin dev
git push --set-upstream origin dev
git pull origin master
  1. 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>