CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Wanting to use github but confused
Pages: [1]

Author Topic: Wanting to use github but confused  (Read 811 times)

ken

  • I live on this forum
  • *****
  • Posts: 916
  • Karma: 53
    • City Bible Forum
  • CiviCRM version: 4.6.3
  • CMS version: Drupal 7.36
  • MySQL version: 5.5.41
  • PHP version: 5.3.10
Wanting to use github but confused
November 17, 2013, 07:40:48 pm
Hi,

I'm trying to follow the 'Github for CiviCRM' instructions to apply a patch against the 4.4 branch. A week ago I succeeded in creating a PR against 'master' but this next step is too much. Can anyone help?

I started with my sites/all/modules/civicrm directory containing the 4.4.1 tarball.

Github:

Though I had an existing kenwest/civicrm-core repository, I forked again from the 4.4 branch of civicrm/civicrm-core. This didn't seem to do anything.

On my machine:

As per the instructions ...

 $  cd /tmp
 $  wget https://github.com/civicrm/civicrm-core/raw/master/bin/gitify
 $  bash gitify git://github.com/civicrm /var/www/drupal/sites/all/modules/civicrm --hooks
 $  cd /var/www/drupal/sites/all/modules/civicrm
 $  git remote set-url origin git@github.com:kenwest/civicrm-core.git
 $  git pull
 $  git remote add upstream git://github.com/civicrm/civicrm-core.git
 $  git fetch upstream
 $  git checkout upstream/4.4 -b CRM-13789

At this point I got messages that a couple of files were out of sync. That seemed wrong, but I continued with the -f force option

 $  git checkout -f upstream/4.4 -b CRM-13789
 $  nano CRM/Report/Form/Campaign/SurveyDetails.php
 $  git add CRM/Report/Form/Campaign/SurveyDetails.php
 $  git diff
 $  git commit -m 'CRM-13789 - alias added to Interviewer filter'
 $  git push origin CRM-13789

GitHub:

Created a pull request https://github.com/civicrm/civicrm-core/pull/2009 but it didn't contain my changes, just some deltas by lobo.

Very confused.

Ken
« Last Edit: November 17, 2013, 10:15:59 pm by ken »

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Wanting to use github but confused
November 17, 2013, 08:08:21 pm
That all looks right to me.
Looks like you're missing the last step (pushing your changes back to github)
>git push origin CRM-13789
Try asking your question on the new CiviCRM help site.

ken

  • I live on this forum
  • *****
  • Posts: 916
  • Karma: 53
    • City Bible Forum
  • CiviCRM version: 4.6.3
  • CMS version: Drupal 7.36
  • MySQL version: 5.5.41
  • PHP version: 5.3.10
Re: Wanting to use github but confused
November 17, 2013, 08:16:08 pm
I redid the steps from scratch but this time I deleted my repo kenwest/civicrm-core before I started.

It seems a bit odd to have to delete a repo. Can't I say "synchronise my repo with upstream/branch"?

(Coleman, I did the git push origin. I'll update the original post.)

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Wanting to use github but confused
November 17, 2013, 09:27:27 pm
I'm not sure what you mean you deleted kenwest/civicrm-core.

The basic idea with a PR is to create a branch based off the latest upstream (civicrm on github), and then push it to origin (your fork on github). Once you do that, you can go to github.com and create a PR from your branch to the appropriate civicrm branch (in this case 4.4). To me it looks like you did everything right but got confused with the last step. The reason you see stray commits from lobo is because you were comparing your branch with master instead of 4.4.

This is the comparison you want: https://github.com/kenwest/civicrm-core/compare/4.4...CRM-13789-1
Try asking your question on the new CiviCRM help site.

ken

  • I live on this forum
  • *****
  • Posts: 916
  • Karma: 53
    • City Bible Forum
  • CiviCRM version: 4.6.3
  • CMS version: Drupal 7.36
  • MySQL version: 5.5.41
  • PHP version: 5.3.10
Re: Wanting to use github but confused
November 17, 2013, 10:09:37 pm
Coleman,

The bit I'm just not getting is how to get my fork on GitHub back in sync with the upstream (eg, upstream has 4,920 commits, while my fork previously had only 4,318 of those).

The instructions at http://wiki.civicrm.org/confluence/display/CRMDOC/GitHub+for+CiviCRM say

How-To: Submit a Patch to a Version Branch
...
2. Go to https://github.com/civicrm/civicrm-core, select the version branch you want to create a patch against such as 4.3 or 4.4, then click Fork to create a fork of that branch in your github account

At that point I already had a fork. Do those instructions assume a fork already exists? Or do they assume it doesn't?

Ken

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Wanting to use github but confused
November 18, 2013, 10:47:57 am
Those instructions assume the fork exists on github. So you can skip that step.
The interesting thing to note is that the state of a personal fork doesn't matter very much.
For example, say your fork on github has the following branches:

master - this will be an out-of-date copy of civicrm/master. No one cares what's in it. Delete it if you wish.
4.4 - an out-of-date copy of civicrm/4.4. No one cares what's in it. Delete it if you wish.
some-old-issue - a branch you used to send a PR to civicrm a while ago. If the PR has been merged the branch no longer matters. Delete it.
some-current-issue - a branch for an active PR. This is the only branch that matters. You can push more commits to it to update the PR. When the PR is closed, delete it.

So now that you have your mostly placeholder fork on github, here's how to use it to send a PR against, for example, 4.4:

>git checkout 4.4 (assuming you have this local branch already. If it doesn't exist yet type 'git checkout upstream/4.4 -b 4.4')
>git pull upstream 4.4
check how you're doing with
>git status
If the pull fails or your git status is not clean do
>git reset --hard HEAD
and try pulling again
now you have an up-to-date copy of civicrm 4.4. You can play with it and try to reproduce the issue you're wanting to fix
whenever you get out-of-date, 'git pull upstream 4.4' again.
If you've made some code changes and want to send a PR, do:
>git checkout -b some-branch-name
>git commit -a -m "CRM-xxx - Added foo bar to whiz bang"
>git push origin some-branch-name
You can now create a PR on github.
If you have more changes to make and want to add them to the PR, do the commit and push again
If you get out-of-date and it really matters (usually being behind by a few commits on a PR branch doesn't matter, but if the upstream changes are something you really need):
>git pull --rebase upstream 4.4
>git push --force origin some-branch-name
when your PR has been merged, delete your branch
>git checkout 4.4
>git branch -d some-branch-name
>git push origin :some-branch-name
Now you can pull to get the latest 4.4 and you're back to work

Note that this doesn't have to be a linear process. If you have more than one PR you are working on at once, you can switch back and forth between branches freely. Just remember that when you first create a branch for a PR, you should always start on the (up-to-date) branch that this PR is for. So note in the example above we were on 4.4 before creating some-branch-name.

Also note that in git there are hundreds of ways to do the same thing and it's largely a matter of personal preference. What I gave you was my own worflow, which works for me. The instructions on the wiki are slightly different but will achieve the same result. For example if you want to skip the step of updating 4.4 locally before creating a PR branch, you can just create the branch directly from upstream
>git checkout upstream/4.4 -b some-branch-name
Try asking your question on the new CiviCRM help site.

ken

  • I live on this forum
  • *****
  • Posts: 916
  • Karma: 53
    • City Bible Forum
  • CiviCRM version: 4.6.3
  • CMS version: Drupal 7.36
  • MySQL version: 5.5.41
  • PHP version: 5.3.10
Re: Wanting to use github but confused
November 18, 2013, 02:32:26 pm
Thanks for taking the time to explain that, Coleman. I suspect I'll have to work through that before I really 'get' it.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Wanting to use github but confused

This forum was archived on 2017-11-26.