From ElectroDragon
Jump to navigation Jump to search

Basic Work flow

Init New

  • Init new by git init, git add file and git commit
  • Set a new repository on github

Add to Remote

  • add local to remote service:
git remote add origin
git remote add origin
  • This one is more easy and save user name and pass: git remote add origin https://{your name}:{you passwd}{your name}/pmoney.git
  1. origin is the alias name for remote repository, here is pmoney.git, you can delete by git remote rm origin, alias can be any name you like
  2. to check all alias like origin use:
git remote -v

Add, Commit and log

  • git add .
  • git commit
  • git commit -m "Add test.rb to test git function"

Git push

  • after added, then add files you worked, then you can push local to remove
git push -u origin master, or git pull origin master
  1. -u means remember the parameter, next time you can only use git push
  2. origin is the alias, and master means the branch
  3. git add and git commit should already be done before first push

Clone or fetch

  • Update to latest git update: git fetch orgin, and need to mergin the orgin to local: git merge origin/master, or use git pull origin master to do it automatically
  • git status to check if anything need to be committed



  • touch
  • git add .
  • stage the difference: git diff --staged
  • git rm *.py or git mv


For the last change

  • git reset // reset to unstage the file
  • git checkout -- // undo all the check on the file since from last commit
  • to cancel the last commit, use git commit --amend


Switch/create branch

  • git branch new // create new branch
  • git branch -d new // delete branch
  • git checkout new // switch branch


  • create a git on github
  • in git gut "add remote", enter name and web address
  • rescan, stage, commit and push


clone all

clone step by step, after clone main reposirity

  • git submodule init
  • git submodule update



git submodule deinit -f stm32_mylib
git rm --cached stm32_mylib


  • git submodule update --init --recursive
  • git submodule update --recursive --remote
  • git pull --recurse-submodules


  • If use http:// or https git clone, only need set export
export http_proxy=""
export https_proxy=""

Global Config

  • git config --global edragon
  • git config --global ""


for ss socks5, use git config --global http.proxy socks5://

for ss socks5, use git config --global https.proxy socks5://

  • git config --global --unset http.proxy
  • git config --global --unset https.proxy
  • git config -l
  • npm config delete proxy

Save password

  • git config credential.helper store

Common Issues

save username and pass

  • set url: git remote set-url origin
  • git config credential.helper store

Use Guide

Other Useful tools


Pages in category "Git"

This category contains only the following page.