add MOODLE_24_STABLE to github.com repository

add MOODLE_24_STABLE to github.com repository

by Gordon Bateson -
Number of replies: 11
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Hello everyone,

following the directions on the Moodle Git for developers page, I have been able to setup a public repository that is a fork of the main Moodle Github repository, and then clone that to make local repositories of the various versions of Moodle 2.x.

I keep the public repository uptodate using the script supplied on the above Moodle docs page. Basically it does a "git fetch upstream" and then "git push origin refs/remotes/upstream/$BRANCH:$BRANCH" for each branch.

Everything was working well, until the new MOODLE_24_STABLE branch was added.

If I try the following: 

git push origin refs/remotes/upstream/MOODLE_24_STABLE:MOODLE_24_STABLE

I get the following error message:

push branch (to github.com): MOODLE_24_STABLE
error: unable to push to unqualified destination: MOODLE_24_STABLE
The destination refspec neither matches an existing ref on the remote nor begins with refs/, and we are unable to guess a prefix based on the source ref.
error: failed to push some refs to 'git@github.com:gbateson/moodle.git'

I think I need to add the MOODLE-24_STABLE branch to my github.com repository somehow, but I can't see how to do that.

Does anybody have any suggestions?

regards
Gordon

Average of ratings: -
In reply to Gordon Bateson

Re: add MOODLE_24_STABLE to github.com repository

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

Hi Gordon,

I guess your problem arises from the fact that it was only at the beginning of this week that moodle's "master" branch was switched to MOODLE_24_STABLE and "master" is now moodle_25. And you did your clone operation before that...

Obviously on your github the MOODLE_24_STABLE branch has not yet been created, hence the error message you are getting.

screenshot #1

What I think you need to do is, on your local moodle repository, to switch to MOODLE_24_STABLE branch. Then to push that branch to your moodle mirror on your github, which will create the missing MOODLE_24_STABLE branch there.

After that, you will be able to git push origin refs/remotes/upstream/MOODLE_24_STABLE:MOODLE_24_STABLE.

However, it might be easier and safer to simply do a fresh clone of moodle on your local machine, now it will include the MOODLE_24_STABLE branch.

I am not a git or github specialist, only a basic user, so my advice may need to be corrected by more savvy users!

Joseph

In reply to Joseph Rézeau

Re: add MOODLE_24_STABLE to github.com repository

by Gordon Bateson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Joseph,
thanks for the reply.

> Obviously on your github the MOODLE_24_STABLE branch has not yet been created

Yes, I think that's what my problem is.

> switch to MOODLE_24_STABLE branch. Then to push that branch to your moodle mirror on your github

Frustratingly, I can't yet see how to do that ?! I am going to have a good look at what Matteo has written.

cheers
Gordon

In reply to Gordon Bateson

Re: add MOODLE_24_STABLE to github.com repository

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

Gordon,

I am using TortoiseGit (for Windows) so I do not know very well the GIT command language.

This is what I can see in the TortoiseGit interface when I want to switch to another branch of moodle:

screenshot #1

Have you considered the option I suggested of doing a fresh clone of Moodle? Now that the 24 branch has been created there should be no problem.

 

In reply to Joseph Rézeau

Re: add MOODLE_24_STABLE to github.com repository

by Gordon Bateson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Hi Joseph,
thanks for the screenshot. Am I right in thinking that this dropdown box is showing you the branches on your "upstream" repository? That is probably "git://git.moodle.org/moodle.git", right?

In that case, I have been able to do what you are suggesting using the following GIT commands:

git clone git://git.moodle.org/moodle.git moodle24
cd moodle24
git branch --track MOODLE_24_STABLE origin/MOODLE_24_STABLE
git checkout MOODLE_24_STABLE

That works fine. My difficulty is something else ... I think.

I understood from the Moodle docs that I should make a fork of the Moodle github repository and then keep that uptodate using the code I gave in my original post. That's what isn't working for me.

I was hoping there should be a simple, elegant way to do it. After all, everyone who follows the Moodle Docs would face the same issue wouldn't they? Forking on github.com doesn't seem very useful to me, if you have to keep watch of when new branches come out, manually add them yourself. I was hoping the process would be more automatic.

Not sure yet what I am confused about ?!
Gordon

In reply to Gordon Bateson

Re: add MOODLE_24_STABLE to github.com repository

by Matteo Scaramuccia -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Hi Gordon,
in the past I spent a big amount of time in learning git - that beautiful beast! smile - and I created my workflow based on what I suppose to be a good non-core sometime-contrib developer environment.

One of my last decisions about my workflow was to use just Windows Git Bash and not TortoiseGit: it gives me more power or just feeling since I'm used to play almost with CLI. FYI: I'm using PhpStorm too to code around Moodle but not its own git integration.

Matteo

Average of ratings: Useful (1)
In reply to Gordon Bateson

Re: add MOODLE_24_STABLE to github.com repository

by Matteo Scaramuccia -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Hi Gordon,
not sure about the right steps, I'm using a git setup slightly different from what suggested in the Moodle Dev Docs and for sure I'm not a git master wink. Here is what I think it could work (verbose steps):

$ git branch
$ git branch --track MOODLE_24_STABLE-upstream upstream/MOODLE_24_STABLE
$ git checkout MOODLE_24_STABLE-upstream
$ git push origin MOODLE_24_STABLE-upstream:MOODLE_24_STABLE
$ git branch --track MOODLE_24_STABLE origin/MOODLE_24_STABLE
$ git branch
$ git checkout MOODLE_24_STABLE

Then, you can remove the MOODLE_24_STABLE-upstream branch.

EDIT: my post has been submitted almost at the same time of Joseph's post (I'm slow when writing in English wink ), conclusions are the same Yes.

HTH,
Matteo

Average of ratings: Useful (1)
In reply to Matteo Scaramuccia

Re: add MOODLE_24_STABLE to github.com repository

by Gordon Bateson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Matteo,
thank you so much for sharing this code. It was really helpful.

In my case, I do not need the temporary "MOODLE_24_STABLE-upstream" branch, or even the "MOODLE_24_STABLE" branch in my local repository. I just want to create add MOODLE_24_STABLE branch to my public repository on github.com.

After lots of trial and error, I shortened the number of commands to the following:

cd /path/to/local/clone/of/my/github.com/repository
git checkout MOODLE_24_STABLE
git push origin MOODLE_24_STABLE:MOODLE_24_STABLE

If you don't need the local MOODLE_24_STABLE branch (I don't), you can then delete it as follows:

git checkout master
git branch -D MOODLE_24_STABLE

That is enough to add the new branch to my github.com repository. After that I can update it in the normal way, i.e. 

git fetch upstream
git push origin refs/remotes/upstream/MOODLE_24_STABLE:MOODLE_24_STABLE

In due course, I will add this information to the Moodle Docs page.

Once again, many thanks
Gordon 

In reply to Gordon Bateson

Re: add MOODLE_24_STABLE to github.com repository

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Hi Gordon

Try this link...

https://moodle.org/mod/forum/discuss.php?d=192524

I keep this Bookmarked so I can use it every time. I need to do this too this weekend! smile

Cheers

Mary

Average of ratings: Useful (1)
In reply to Mary Evans

Re: add MOODLE_24_STABLE to github.com repository

by Gordon Bateson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Hi Mary,
thanks very much for the link. It was really helpful.

Combined with the code that Matteo suggested, your link helped me to realize, finally, that what I had to do was "checkout" the 24 branch on my local machine, and then "push" it to github.com. It's simple when you know smile.

With your help, I was able to move forward, so many thanks for that.

best regards
Gordon

In reply to Gordon Bateson

Re: add MOODLE_24_STABLE to github.com repository

by Gordon Bateson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Hi Mary - and other folks who need to create new Moodle branches on github.com,

I have created a Bash script which will update *all* branches on your public fork of Moodle's official git repository, adding the new ones where necessary.

It will detect all branches that exist on the "upstream" repository (i.e. git.moodle.org). It will check whether or not each branch exists on the "origin" repository (e.g. github.com).

If a branch exists on the origin, it will be updated. If a branch does not exist, it will be created. This will all happen automagically, so you won't have to try to remember what to do when a new STABLE branch appears. The script will take care of it for you.

I developed the script on a Mac. You are welcome to use it, but bare in mind that you may need to change some of the paths to get it to work on your system.

The script is attached to this message as  "txt" file. You may need to save it on your system with a different file extension (e.g. ".sh") and give it execute permissions, in order for it to run on your system. I hope it is useful for you.

regards
Gordon

Average of ratings: Useful (1)