Skip to content

Instantly share code, notes, and snippets.

@wilmoore
Created November 6, 2012 17:30
Show Gist options
  • Save wilmoore/4026201 to your computer and use it in GitHub Desktop.
Save wilmoore/4026201 to your computer and use it in GitHub Desktop.
My Current Git Topic Branch Workflow

Housekeeping:

% git checkout master
% git pull upstream master
% git push origin master

Start new topic, edit/add files, commit:

% git checkout -b Random-Topic
% $EDITOR .
% git add .
% git commit -am 'JIRA-NNN: description of what was done'
% ...
% git commit ...
% git checkout master
% git pull upstream master
% git checkout -b JIRA-NNN-Random-Topic
% git squash Random-Topic
% git commit -a
% git hub pull-request

NOTE (1): The final git commit -a is where you should provide a more detailed commit message; likely the same text that you'd put into the pull request.

NOTE (2): When in vim(1), I drop to a shell with <ctrl>+z; execute git commands, then go back to vim(1) by typing fg then <enter>.

NOTE (3): I use the git-hub extension (shameless plug) to perform the git hub pull-request command.

@nuttycom
Copy link

This works well about half the time; the other half, the squash will nuke your nice history if you've merged from anywhere else along the way. Most of the time I prefer to rebase -i (with selective squashing) instead of one big squash anyway; better to make the commits into nice logical blocks with.

Also, (2) indicates that you're using vim in a terminal without the benefit of tmux. This is a serious error. :)

@wilmoore
Copy link
Author

@nuttycom: Hey, thanks for the comments. I totally hear you regarding the squashed history...yeah, that can be an issue; I'm seeing that Github pull requests generally mitigate the need to do a lot of squashing anyhow, so I may re-think this being my default workflow.

Regarding (2): YES!!!, I've been investigating tmux; though, I haven't given it the attention it deserves just yet. That being said, I've recently started using vim-fugitive a lot more and it seems to provide me a lot of what I want. Still, I need to spend more time with tmux. Agreed :)

@nuttycom
Copy link

When you start using tmux, make sure to remap your CapsLock key as an additional ctrl, and use Ctrl-a as your mode key instead of Ctrl-b. Then it just becomes a chord.

Another vim tip: add the following to your .vimrc

inoremap jk

This allows you to use the "jk" sequence in insert mode instead of escape. It's awesome, a chord for esc on the homerow. You can also do kj if that's more natural. Neither key sequence is common, though I use jk since my initials are 'kjn' which makes kj more common for me than for most.

@nuttycom
Copy link

Oops, apparently github flavored markdown ate my inoremap.

inoremap jk <esc>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment