Git'ing It Done!
Tehmasp Chaudhri | @tehmaspc
  • the following notes cover my personal git workflow; understand your (team's) git workflow.
  • i prefer a clean git log with meaningful commit messages.
  • i prefer to squash superfluous commits.
  • i prefer merge messages for master.
  • i feature branch and do pull requests.
  • i delete old feature branches.
git --version
% date
Mon May 25 09:36:59 MDT 2015

% git --version
git version 2.4.1

% which git
cat ~/.gitconfig
	name = Tehmasp Chaudhri
	email =
	autosetuprebase = always
	ff = no
	rebase = true
	default = simple
	ui = true
	helper = cache --timeout 600
git branch
# list all branches, verbosely
% git branch -av

# create a new branch
% git branch <new_branch>
% git checkout -b <new_branch>
% git checkout -b <new_branch> -t master          (local)
​% git checkout -b <new_branch> -t origin/master   (remote)

# delete a local branch
% git branch -d <branch>   (safe, if already merged)
% git branch -D <branch>   (force delete, regardless of merge status)

# delete a remote branch
% git push origin :<branch>

# rename branch
% git branch -m <new_name>
git add -p
% git add -p
diff --git a/.gitignore b/.gitignore
index e69de29..cba7efc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1 @@
Stage this hunk [y,n,q,a,d,/,e,?]? y
% git show
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)
    new file:   .gitignore
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)
    modified:   main.c
git rebase -i HEAD~N
% git status
On branch development
Your branch is ahead of 'master' by 2 commits.
  (use "git push" to publish your local commits)
nothing to commit, working directory clean
% git rebase -i HEAD~2
   ... <pick> or <squash> your commits ...
   ... update your COMMIT_MSG ...
% git rebase -i HEAD~2
[detached HEAD 8fa0a6a] - ... <UPDATED COMMIT_MSG> ...
 Date: Mon May 25 13:08:47 2015 -0600
 3 files changed, 8 insertions(+)
 create mode 100644 lib/a.c
 create mode 100644 lib/b.c
Successfully rebased and updated refs/heads/development.
moar git tools


moar git posts

Git'ing It Done!

By Tehmasp Chaudhri

Git'ing It Done!

Git Tips and Tricks

  • 1,979