Git'ing It Done!
Tehmasp Chaudhri | @tehmaspc
disclaimer
  • 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
/usr/local/bin/git
cat ~/.gitconfig
[user]
	name = Tehmasp Chaudhri
	email = tehmasp@gmail.com
[branch]
	autosetuprebase = always
[merge]
	ff = no
[pull]
	rebase = true
[push]
	default = simple
[color]
	ui = true
[credential]
	helper = cache --timeout 600
[alias]
	...
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 @@
+a.out
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
questions?
Made with Slides.com