Up today, I think I will have a look-see at what's new in fab.js land. I am working in my own fork of fabjs. There are a couple of tweaks in my fork that I need, but that Jed did not pull in, so my preference is to keep working in my fork, but tracking his changes.
So first up I'll try to remember how to sync up my fork with Jed's so that I can pull the new branch.
Hrm...
OK new plan. I'll look it up on help.github.com. Dunno if this will ever be something that I will just know or if it will always require a lookup. Anyhow...
Following along, I need to add the upstream repos:
cstrom@whitefall:~/repos/fab$ git remote add upstream git://github.com/jed/fab.gitNext, I need to merge the upstream changes that Jed has made into my local repository:
cstrom@whitefall:~/repos/fab$ git fetch upstream
remote: Counting objects: 66, done.
remote: Compressing objects: 100% (57/57), done.
remote: Total 58 (delta 30), reused 0 (delta 0)
Unpacking objects: 100% (58/58), done.
From git://github.com/jed/fab
* [new branch] master -> upstream/master
* [new branch] v0.5 -> upstream/v0.5
cstrom@whitefall:~/repos/fab$ gba
* master
remotes/origin/HEAD -> origin/master
remotes/origin/master
remotes/upstream/master
remotes/upstream/v0.5
cstrom@whitefall:~/repos/fab$ git merge upstream/masterFinally I push those changes to my github fork:
Auto-merging apps/fab.nodejs.js
Merge made by recursive.
README.md | 2 +-
apps/fab.nodejs.js | 2 +-
package.json | 42 ++++++++++++++----------------------------
3 files changed, 16 insertions(+), 30 deletions(-)
cstrom@whitefall:~/repos/fab$ git statusEasy enough, except... that only pushes the changes to master to my fork. How do I get the new branch pushed to my fork?
# On branch master
# Your branch is ahead of 'origin/master' by 7 commits.
nothing added to commit but untracked files present (use "git add" to track)
cstrom@whitefall:~/repos/fab$ git push
Counting objects: 34, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (24/24), done.
Writing objects: 100% (24/24), 2.82 KiB, done.
Total 24 (delta 16), reused 0 (delta 0)
To git@github.com:eee-c/fab.git
72ec43b..31e4d6b master -> master
After looking around github a while, I fail to locate the copy-branch-from-a-fork button. My google-fu fails me as well. I suppose I could try to push my way through. It is a bit low-level, but I would guess that my first step ought to be creating a new, local branch. I can then merge in the upstream changes and then push that to my forked copy on github.
Sounds like a plan. Maybe.
Creating the new, local branch:
cstrom@whitefall:~/repos/fab$ git co -b v0.5Now I merge in Jed's upstream changes:
Switched to a new branch 'v0.5'
cstrom@whitefall:~/repos/fab$ gba
master
* v0.5
remotes/origin/HEAD -> origin/master
remotes/origin/master
remotes/upstream/master
remotes/upstream/v0.5
cstrom@whitefall:~/repos/fab$ git merge upstream/v0.5Wha?!
Removing LICENSE.txt
Auto-merging README.md
CONFLICT (content): Merge conflict in README.md
Removing apps/fab.body.js
Removing apps/fab.capture.at.js
...
Automatic merge failed; fix conflicts and then commit the result.
Indeed,
git-status
confirms, I have conflicts:cstrom@whitefall:~/repos/fab$ gstBah! That is not right. This is one of the very few cases that I know I want to
# On branch v0.5
# Changes to be committed:
#
# deleted: LICENSE.txt
# deleted: apps/fab.body.js
# deleted: apps/fab.capture.at.js
...
# Unmerged paths:
# (use "git add/rm..." as appropriate to mark resolution)
#
# both modified: README.md
# deleted by them: apps/fab.nodejs.js
git reset --hard
. I have myself a merge conflict and I just want to restart. So:cstrom@whitefall:~/repos/fab$ git reset --hardSolid. I recovered from that little gaff. But what caused the gaff?
HEAD is now at 31e4d6b Merge remote branch 'upstream/master'
It takes me a bit, but I eventually realize that Jed has done work on master since he branched
v0.5
. But I made my local branch from HEAD in master. I should have branched at the same point that he did. Fortunately, that is not that difficult. He branched after a618ff9b73832e879161. To do the same, I simply need to supply that as the reference point for my local v0.5
branch:cstrom@whitefall:~/repos/fab$ git co -b v0.5 a618ff9b73832e879161Now, I can safely merge from upstream:
Switched to a new branch 'v0.5'
cstrom@whitefall:~/repos/fab$ git merge upstream/v0.5And, finally push my changes to my fork on github:
Updating a618ff9..ebc9ef1
Fast-forward
LICENSE.txt | 20 ---
README.md | 145 ++++++++++++++++--
apps/fab.body.js | 39 -----
apps/fab.capture.at.js | 16 --
apps/fab.capture.js | 12 --
...
delete mode 100644 examples/date.js
delete mode 100644 examples/focus.js
delete mode 100644 examples/hello.js
delete mode 100644 examples/index.js
delete mode 100644 package.json
create mode 100644 server.js
delete mode 100644 utils/build.js
delete mode 100644 utils/test.js
cstrom@whitefall:~/repos/fab$ gp origin v0.5Now I have my own nice, shiny fabjs v0.5 on my fork.
Counting objects: 39, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (35/35), done.
Writing objects: 100% (36/36), 9.24 KiB, done.
Total 36 (delta 15), reused 0 (delta 0)
To git@github.com:eee-c/fab.git
* [new branch] v0.5 -> v0.5
Nice. It was really cool to get through all that. I still feel as though I have a long way to go with git before I really understand it, but I was pleased to be able to work through that without getting hopelessly lost.
The basic flow:
git remote add upstream git://github.com/jed/fab.git # insert your git repos here
git fetch upstream
git checkout -b v0.5 a618ff9b73832e879161 # insert branch name and SHA1 of forked-from branch point here
git merge upstream/v0.5 # insert forked-from branch here
gp origin v0.5 # use your branch here
Still, there has to be a better way of pulling in a new branch from upstream. Right?
Day #214
I still have a long way to go too, but this might help: `git pull` is the same as `git fetch` and then a `git merge`.
ReplyDeleteNot positive, but I don't think that would work in this case. From http://help.github.com/forking/:
ReplyDeletegit pull is a more direct way, but the merge it performs can be confusing if the user doesn’t expect it and a merge conflict results. git fetch will also grab all branches, where git pull grabs only the one specified.
Personally, I need to keep potential confusion to a minimum. Even if that were not a potential problem, I am specifically trying to get the new upstream branches. If help.github is accurate, then `git pull` won't grab those branches -- just the current branch.
Regarding your the last paragraph of the previous comment Chris, I'm pretty sure if you've checked out other branches and they are set to track their upstream counterparts, a lone `git pull` WILL grab those branches.
ReplyDelete