git git git notes ######### .. contents:: Set a local repo or global username .. code-block:: bash 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: .. code-block:: bash git push origin master else: .. code-block:: bash 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 .. code-block:: bash 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) .. code-block:: bash 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 .. code-block:: bash git remote add upstream https://github.com/saltstack/salt.git git fetch upstream 2. view all branches .. code-block:: bash 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 .. code-block:: bash git pull upstream develop 4. push local to remote origin .. code-block:: bash git push origin how to set the git commit editor .. code-block:: bash git config –global core.editor “vim” how to enable colorful ui and diffs .. code-block:: bash git config –global color.ui true