Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save vasanthela/76c2c582b08d0d142195 to your computer and use it in GitHub Desktop.
Save vasanthela/76c2c582b08d0d142195 to your computer and use it in GitHub Desktop.
Working around having to merge with master often

Working around having to merge with master often

Sometimes, when working with web frameworks like django/rails, one often has to run database migrations based on the latest master. But this can pose a problem when master could often have problems because multiple developers are changing code rapidly. Or can be a problem when updating to the latest master takes a lot of time, for example running migrations on django can take a while.

A way to avoid this is to work off a local version of master that that has been setup and migrated locally, and avoid continually following master.

1. Setup local version of master

# Assume sha ab1234 is the sha we want to track against in master for local development

git checkout master
git pull
git checkout -b master_working
git reset --hard ab1234

2. Doing some development work on local working master

git checkout master_working
git checkout -b feature_branch_working
... make code changes ...
git add
git commit

3. Submitting a pull request against latest master

# on git branch feature_branch_working
git checkout -b feature_branch
git rebase master
git push origin feature_branch
# submit pr merging feature_branch against master

4. Continuing work and updating feature_branch for pr

git checkout feature_branch_working
... make code changes and test locally ...
git checkout feature_branch
git merge feature_branch_working
git push origin -f feature_branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment