Login or register    

git notes

Set a local repo or global username

git config --local user.name "fox"
git config --local user.email "fox@localhost"

git config --global user.name "foxhop"
git config --global user.email "foxhop@foxhop.net"

How to push to remote master

if this is your first commit/push:

git push origin master

else:

git push

Basic github workflow

upstream

original remote github repo, read-only

only way to change this repo is to ask for a merge using a pull-request

origin

forked remote github repo, read-write

push you changes here and perform pull requests

local

cloned local, read-write

make changes and push to origin

pull changes from upstream, perform merges and fast forwards to keep sync'd

example using salt repo

  1. create a remote fork on github

    press the fork button when logged in

  2. clone the remote fork to your local host

    cd ~/git
    git clone https://github.com/russellballestrini/salt.git
    cd salt
    
  3. make some changes to source code and push to remote origin (your github fork)

    git add .
    git commit
    git push
    
  4. perform a pull-request using github gui


Go on vacation for 1 week
Your local and origin repos now appear out-of-date. Sync them by performing a fast-forward or merge with upstream.

  1. Tell your local repo about the upstream repo

    git remote add upstream https://github.com/saltstack/salt.git
    git fetch upstream
    
  2. view all branches

    git branch -a
    
    * develop
     remotes/origin/0.11
     remotes/origin/0.12
     remotes/origin/0.13
     remotes/origin/HEAD -> origin/develop
     remotes/origin/develop
     remotes/origin/master
     remotes/origin/no_ipv6
     remotes/upstream/0.11
     remotes/upstream/0.12
     remotes/upstream/0.13
     remotes/upstream/develop
     remotes/upstream/master
     remotes/upstream/no_ipv6
    
  3. sync local with remote upstream

    git pull upstream develop
    
  4. push local to remote origin

    git push origin
    

how to set the git commit editor

git config --global core.editor "vim"

how to enable colorful ui and diffs

git config --global color.ui true

Comments

Leave a comment

Please login or register to leave a comment!