
Rebasing a branch (remote sync)
Technical ·Friday September 10, 2010 @ 23:00 EDT (link)
While there may be better ways to do this, the way I have found to do a remote sync and ensure that the unpushed changes in my local branch of my git repository are kept around is:
git co master (switch to main branch)
git pull --rebase (apply remote changes)
git co scraper-abstraction (back to my branch)
git rebase master (apply pulled changes to my branch)
Some of these may be unnecessary or extra steps, e.g. because some of the commands take a branch, so co (which I have aliased to checkout) may be unnecessary. I may be able to just do a pull into my branch, something like (on scraper-abstraction):
git pull --rebase <remote repository URL?>
and now that I think of it it probably makes no sense to rebase master; since master is "remote-tracking" (which is the reason I don't need to tell it the remote URL?), a plain git pull (merge) should suffice, followed by, as before, a switch back to my branch and a rebase from master.
After the git rebase, my (local) commits that had been committed to the remote repository disappeared, which was as expected (of course, they exist at the point they were committed to master).
Still trying to figure all this out, so help from experts is welcome.