How to add more Git Tiki branches after you cloned a single oneAuthor: Bernard Sfez -
Outside development scope, I usually setup my Tiki instance as compact as possible cloning the last revision and a single branch.
However I needed to cherry-pick a commit onto 2 branches and for some reasons Gitlab, where I keep my repositories wasn't able to do it automatically as it does usually.
I had to go under my git config hood to rerouting cables and add a second branch to my existing origin/master.😉
First of all, words wisdom. There may be other ways to do this I'm not Git guru I'm just a guy that need to have things done quickly to reach my goal.
This was a kind of side and distracting but necessary action so I took the road and fix the issue.
How I get into to the issue
When I setup a Tiki CMS Groupware or any other project instance for production, I clone only what I need to avoid dragging a 5gb project on the customer infrastructure.
I use the git clone command as explained on some of my Tiki Express tutorials I "download" only the last code (not all the different alteration and comments) for a single branch (not all the repository).
So, after updating a Tiki (this one) from Tiki version 23 to Tiki24 and testing it I found some new strings that weren't't translated yet in Hebrew.
During a release process code should be first committed to master then cherry-picked to the branch(es) you choose. More details here.
Following the guideline of the Tiki Wiki Open Source development coders community I committed and merge my changes to master. Once done I tried to cherry-pick the merge to the branch Tiki24 using Gitlab tools. I went to the merge page and under the "Options" dropdown selected "Cherry-pick". This opened a modal to allow me to select the destination branch and I selected 24.x and submit.
But the feedback was not the one I expected as I did this before in the past many times;
_Sorry, we cannot cherry-pick this commit automatically. This commit may already have been cherry-picked, or a more recent commit may have updated some of its content._
After checking and retrying I understood I need to cherry-pick locally.
What was the problem
As explained above, my setup has ONLY the master branch and is not even aware of other branches.
So I had to modify my git config manually to allow git to fetch other branch than the one in the config.
How to add other branches when you deliberately cloned a single one
I went into project directory and edited the git config file;
There I search the part that define the origin;
url = git at gitlab.com:bsfez/tiki.git
fetch = +refs/heads/master:refs/remotes/origin/master
I replaced "master" for wildcard "*" on the fetch line
fetch = +refs/heads/*:refs/remotes/origin/*
I fetch the repository to refresh the useable branches and get all the branches
$ git fetch Enter passphrase for key ........: remote: Enumerating objects: 722113, done. remote: Counting objects: 100% (660075/660075), done. remote: Compressing objects: 100% (129034/129034), done. remote: Total 652645 (delta 520308), reused 649762 (delta 517852), pack-reused 0 Receiving objects: 100% (652645/652645), 2.97 GiB | 5.86 MiB/s, done. Resolving deltas: 100% (520308/520308), completed with 4409 local objects. From gitlab.com:bsfez/tiki .../... * [new branch] 16.x -> origin/16.x * [new branch] 17.x -> origin/17.x * [new branch] 18.x -> origin/18.x * [new branch] 19.x -> origin/19.x * [new branch] 2.0 -> origin/2.0 * [new branch] 20.x -> origin/20.x * [new branch] 21.x -> origin/21.x * [new branch] 22.x -> origin/22.x * [new branch] 23.x -> origin/23.x * [new branch] 24.x -> origin/24.x * [new branch] 3.0 -> origin/3.0 .../...
After that I was able to switch branches and work on Tiki 24.x
Epilogue; back-porting manually using phpStorm
To develop and maintain my Tiki instances I'm using phpStorm .
In phpStorm I checkout Tiki branch 24.x
Open the Git section, selected my commit and cherry-picked... but there too it failed.
Seems something added in the code between the little time I rebased my original files version and merged my changes something was changed.
So from the branch Tiki 24.x I checkout a new branch "Hebrew_translation_24x".
Then I switched back to the branch Ithat contains my changes, "Hebrew_translation" and, in the phpstorm, I compared my file version and the branch 24.x version.
Using the merge tool, I manually merged the string that were newly translated.
Then I pushed back the branch "Hebrew_translation_24x" and merged it with the Tiki 24.x branch following the instructions you can find on my Tiki Express tutorials about development in Tiki and https://dev.tiki.org/Git-Workflow
If you are still reading I guess it helped you in some way and that's important to me.
If you read this from a social network link, shared, follow and like.
To know more about my publication or video tutorials and want to received a notification when I’ll publish, subscribe to my youtube channel, I will also start to communicate using a newsletter this year so you can register on my homepage.
Be seeing you !