Showing posts with label branch. Show all posts
Showing posts with label branch. Show all posts

Saturday, April 20, 2013

Git make "clean" pull request.

Scenario: You've worked your tail off and *know* you're done with .. whatever you're working on, and can't be bothered to fixup/squash/commits properly to hide your work method to send upstream.

you have the most recent git fetch from upstream and you're ready to do a pull request.

git checkout upstream/master
(you get a warning that you're in headless mode. In this case, great, let's do what it says:)

git checkout -b mybranchforthispullrequest

Now you're basically looking at plain upstream/master.

you can either
git merge mylocalworkingbranch (but this keeps the commit history)

or, if you're *certain* you only want to add/replace files (hopefully, only add)
git checkout mylocalworkingbranch myfileiwanttoadd.ext

git add myfileiwanttoadd.ext

git commit -m "Added myfileiwanttoadd.ext"

and just send the branch to your origin or upstream
git push origin mybranchforthispullrequest

Optionally, go to github and do a pull request from mybranchforthispullrequest.


Friday, January 18, 2013

git branch before pull

Things are going well on your version of production/master and you'd like to pull the latest iteration. Oh, sure, you could tar your setup before doing that in case it breaks, but maybe you're stuck for time and too lazy. That's okay. Really it is. just
git branch before-pull-todaysdate
git pull

PANIC! bad stuff, things crashing, etc... maybe that pull isn't nice.
git checkout before-pull-todaysdate

whew... sanity restored. ... OK, it's off hours and you really want to get back to the latest iteration. Managers aren't on your back and you can fix this.
git checkout master

errors, etc. but at least you're at the latest iteration.

BETTER: don't pull. Just git fetch, then git merge when you're ready.

Monday, January 14, 2013

git branch change oops wrong branch

Specific case:

You're working on a feature but forgot to change branches. This feature is going to corrupt master, it seems, but you haven't committed yet.

alternative to stash,
git branch newbranchname
git checkout newbranchname
git add .
git commit -m "I needed a branch for this before killing master"

if you git checkout master, all these new previously uncommitted changes aren't there (whew) but git checkout newbranchname has the stuff you've been working on.

when you're ready to put them back, just merge back to master.

Blog Archive