Using git with drupal

From Freephile Wiki
Jump to navigation Jump to search

I forked the drupal project from git://github.com/mikl/drupal.git (my "origin") so that I could start with official upstream drupal sources. I then created my own private remote repository that I can push to (iic-drupal), and have made a number of commits (using a different computer). Now I'm on a machine where I want to pull from iic-drupal, but if I do 'git pull' it complains (see below). This gist describes how I fixed my configuration, and clears up for me how in a DISTRIBUTED VCS, you need to tell the system which local branch you are working with, and equally important, which remote AND branch on that remote you want to pull code from.

$ cat .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = /home/greg/work/gr/drupal/.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
$ git branch
* iic-dev

master
$ git pull
From git://github.com/mikl/drupal
99fdab0..eaeb980 CVS -> origin/CVS
8d31470..2d0b3a5 DRUPAL-5 -> origin/DRUPAL-5
f4ab67a..adc30ae DRUPAL-6 -> origin/DRUPAL-6
99fdab0..eaeb980 master -> origin/master
From git://github.com/mikl/drupal
* [new tag] DRUPAL-5-17 -> DRUPAL-5-17
* [new tag] DRUPAL-5-18 -> DRUPAL-5-18
* [new tag] DRUPAL-6-11 -> DRUPAL-6-11
* [new tag] DRUPAL-6-12 -> DRUPAL-6-12
You asked me to pull without telling me which branch you
want to merge with, and 'branch.iic-dev.merge' in
your configuration file does not tell me either. Please
name which branch you want to merge on the command line and
try again (e.g. 'git pull <repository> <refspec>').
See git-pull(1) for details on the refspec.

If you often merge with the same branch, you may want to
configure the following variables in your configuration
file:

branch.iic-dev.remote = <nickname>
branch.iic-dev.merge = <remote-ref>
remote.<nickname>.url = <url>
remote.<nickname>.fetch = <refspec>

tell git to pull (fetch and merge into the local branch) code from the "iic-drupal" remote, using the "iic-dev" branch found there.

$ git pull iic-drupal iic-dev
From git@svn.iic.harvard.edu:repositories/drupal
* branch iic-dev -> FETCH_HEAD
Updating 6a9bc15..b03005b
Checking out files: 100% (63407/63407), done.
Fast forward
$ git branch -a
* iic-dev
master
iic-drupal/iic-dev
iic-drupal/master
origin/CVS
origin/DRUPAL-3-0
origin/DRUPAL-3-00
origin/DRUPAL-4-0
origin/DRUPAL-4-1
origin/DRUPAL-4-2
origin/DRUPAL-4-3
origin/DRUPAL-4-4
origin/DRUPAL-4-5
origin/DRUPAL-4-6
origin/DRUPAL-4-7
origin/DRUPAL-5
origin/DRUPAL-6
origin/HEAD
origin/drop
origin/master

tell my local repository that the local branch "iic-dev" has a remote repository to track called "iic-drupal" (already defined in "remotes")

$ git config branch.iic-dev.remote iic-drupal

tell my local repository that the local development branch "iic-dev" should be merged with code fetched from the remote development branch (also called "iic-dev")

$ git config branch.iic-dev.merge iic-dev