User Tools

Site Tools


Better than subversion as you can make local commits. Also, apparently like Ferrari compared to Hyundai

  • Simple Overview seems good. Git book seems good
  • It appears that git remote merges all of your commits (and messages) so it keeps a history of everything.
  • Gitk > qgit > Gitg (minimalist, but annoying)
  • Don't let a commit hit trunk/“master” unless it's gone through Basic Acceptance Testing. It feels “slower”, but I bet it's a lot faster too.
    • One way to do this is to have a read-only master branch. Every attempt must be on a separate branch which is reviewed separately. Then integrated if passes by the build system.
  • Graphical Git GUI. Unfortunately not much traction, but useful for intro people.
  • How to lose data in Git, by CMU OS professor Dave Eckhardt. Basically, anything not pushed isn't going to get saved. Makes sense…

Fast clone

Commit/push checklist

  1. 'git add –all .'
  2. 'git status', make files you want to ignore are not included
  3. 'git diff <master_name>', make sure no unintended changes
  4. 'git commit -m “<meaningful description of what you changed>”', as 'git log' only prints the messages, not the diff
  5. 'git push origin <branch-name>'
  6. Revise ReviewBoard title and comments to have meaningful statements like Jonathan
    1. Also, update “Testing Done” section in ReviewBoard?

Common git commands

Meaning Command
Create git repo in current directory git init .
Ignore .pyc files Edit <rootdir>/.git/info/exclude and append *.pyc 1
I use *.pyc, *.dropbox, *.o
Add/scan for new files git add .
Commit git commit -m “<commit message>”
Add a remote repo (TODO: only do a subset?) git remote add origin
Commit to remote repo. Not sure what -u is for git push -u origin master
Add “upstream” repo git remote add upstream
Pull changes from remote repo git fetch origin
Check out and track remote branch git checkout –track origin/newsletter
Update local changes with remote changes git pull that's it?!?!
Change branches / commits (be sure to cd inside of directory) git checkout feature/hal or git checkout 01234567
Git bisect (find bugs using binary search)!
Add all modified files (don't have to do git rm from cmd line) git add -A .
Delete All Branches older than XX weeks
for k in $(git branch | sed /\*/d); do 
  if [ -z "$(git log -1 --since='1 week ago' -s $k)" ]; then
    git branch -D $k

(stackoverflow is wrong)

Create patch file git diff 01234567^! --ignore-all-space > diff.patch
Revert local working copy / uncommitted files git reset --soft HEAD^
View git log git reflog
UNDO STUFF git reset --hard HEAD@{X}
Find by tag git tag -l “*971*”
Checkout tag git checkout tags/SPS_IA_54.00.01.971.0
Ignore branch merges git log –no-merges –first-parent , or just use GitExtensions and view current branch only
Interactive rebase git rebase -i <branch name whose commits you want to diff from, usually master>
(will rewrite the history of the current branch you're on, so you might want to make a new branch first)
Interactive checkout / diff \ Used for reverting changes from master for a selective push git checkout -p <other branch>
Revert is not a reset! If you merge a separate branch but then don't want to actually do it. Reverting is not good enough. You have to reset –hard HEAD to delete the merge commit or in the worst case do an interactive rebase. Otherwise the branch commits are in your branch, they're just undone with a separate commit!
  • Something with Github….
  • To setup a server, use git init --bare and not git init ., more info here

Git graph drawing demo

Installing Git on Windows

Cloning a git repository

I know enough from hacking around on git to get it working for me, but I am by no means an expert!

To set it up on your computer:

  • Install git (install, set up SSH keys, username, etc.)
  • Navigate to the parent directory of where you want the repository to be stored
  • Run 'git clone' Should clone the repository and automagically set up git, etc.

w00t, you now you have a working clone of a repository! To work on the code:

  • Pull down changes by running 'git pull origin master'
  • Work on the current copy of the code.
  • When you're done and ready to push your changes, run 'git add .', then 'git commit -m “<update message>” ', and finally 'git push origin master'

Gitting it working

Unable to negotiate with XX.XXX.XX.XX: no matching host key type found. Their offer: ssh-dss fatal: Could not read from remote repository.

For me this worked: (added into ~\.ssh\config)

Host *

HostkeyAlgorithms +ssh-dss

PubkeyAcceptedKeyTypes +ssh-dss


Just because.

To see changes based on an ID use Search→Go To→123456

Use find file or find by change set (Ctrl+G) to find what you're looking for.

Too bad there's not, “within this file find diff containing foo”, but maybe there is!

programming/git.txt · Last modified: 2020/10/26 09:18 by admin