Using git with drupal: Difference between revisions
m added Category:Drupal using HotCat |
m Text replacement - "<(\/?)source" to "<$1syntaxhighlight" Tags: Mobile edit Mobile web edit |
||
Line 1: | Line 1: | ||
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. | 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. | ||
< | <syntaxhighlight lang="bash"> | ||
$ cat .git/config | $ cat .git/config | ||
</ | </syntaxhighlight> | ||
<pre> | <pre> | ||
[core] | [core] | ||
Line 17: | Line 17: | ||
</pre> | </pre> | ||
< | <syntaxhighlight lang="bash"> | ||
$ git branch | $ git branch | ||
</ | </syntaxhighlight> | ||
<pre> | <pre> | ||
* iic-dev | * iic-dev | ||
Line 25: | Line 25: | ||
master | master | ||
</pre> | </pre> | ||
< | <syntaxhighlight lang="bash"> | ||
$ git pull | $ git pull | ||
</ | </syntaxhighlight> | ||
<pre> | <pre> | ||
From git://github.com/mikl/drupal | From git://github.com/mikl/drupal | ||
Line 57: | Line 57: | ||
tell git to pull (fetch and merge into the local branch) code from the "iic-drupal" remote, using the "iic-dev" branch found there. | tell git to pull (fetch and merge into the local branch) code from the "iic-drupal" remote, using the "iic-dev" branch found there. | ||
< | <syntaxhighlight lang="bash"> | ||
$ git pull iic-drupal iic-dev | $ git pull iic-drupal iic-dev | ||
</ | </syntaxhighlight> | ||
<pre> | <pre> | ||
From git@svn.iic.harvard.edu:repositories/drupal | From git@svn.iic.harvard.edu:repositories/drupal | ||
Line 68: | Line 68: | ||
</pre> | </pre> | ||
< | <syntaxhighlight lang="bash"> | ||
$ git branch -a | $ git branch -a | ||
</ | </syntaxhighlight> | ||
<pre> | <pre> | ||
* iic-dev | * iic-dev | ||
Line 95: | Line 95: | ||
tell my local repository that the local branch "iic-dev" has a remote repository to track called "iic-drupal" (already defined in "remotes") | tell my local repository that the local branch "iic-dev" has a remote repository to track called "iic-drupal" (already defined in "remotes") | ||
< | <syntaxhighlight lang="bash"> | ||
$ git config branch.iic-dev.remote iic-drupal | $ git config branch.iic-dev.remote iic-drupal | ||
</ | </syntaxhighlight> | ||
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") | 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") | ||
< | <syntaxhighlight lang="bash"> | ||
$ git config branch.iic-dev.merge iic-dev | $ git config branch.iic-dev.merge iic-dev | ||
</ | </syntaxhighlight> | ||
[[Category:Drupal]] | [[Category:Drupal]] |
Latest revision as of 13:29, 24 February 2025
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