Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
#
# git move-commits num-commits correct-branch
#
# moves the last n commits to correct-branch
# if correct-branch doesn't exist, it creates it
# if correct-branch does exist, it merges the commits
if [ $1 ]
then
@washingtontimes
washingtontimes / git-finish-branch.sh
Created March 16, 2010 10:25
Merges a branch and tags it. Then pushes it out and deletes the branch.
#!/bin/bash
#
# Called as git finish-branch branch [tag]
#
# * Merges a branch into the master branch (with no-ff)
# * Tags the merge with either the passed tag or the date in the form MMDDYYYY
# * Pushes the changes to the origin repository
# * Deletes the branch
ICOUNT=1
@washingtontimes
washingtontimes / git-status-u.sh
Created March 16, 2010 10:18
A git command that emulates svn status -u and shows what will be updated with the next pull.
#!/bin/bash
git fetch
git log --name-status ..origin/master | grep -P '[ACDMRTUXB]\t'
@washingtontimes
washingtontimes / git-push-branch.sh
Created March 16, 2010 10:17
A git command to push a local branch to the origin repository.
#!/bin/bash
function push_branch () {
HAS_REMOTE=`git show-ref remotes/origin/$1`
HAS_LOCAL=`git show-ref heads/$1`
if [[ $HAS_REMOTE ]]; then
echo "The remote repository already has a branch named $1"
exit
@washingtontimes
washingtontimes / Django app auto-import
Created September 14, 2009 17:30
Django app auto-import
import importlib, os
APP_DIRS = (os.path.abspath(os.path.join(PROJECT_ROOT, 'test')),)
sys.path.extend(APP_DIRS)
BASE_URL_CONFS = []
for app_dir in APP_DIRS:
for app in os.listdir(app_dir):
if not app.startswith('.') and app not in INSTALLED_APPS:
try:
app_settings = importlib.import_module('%s.settings' % app)
if getattr(app_settings, 'APP_NAME', '') != '':