2015-06-13, 10:06
How to Clone/Fork a Kodi GitHub Repository
*Alternative approach using tortoisegit.
This is a detailed tutorial on how to fork a GitHub repository and keep it in-sync with the original branch. This should be of particular interest to those interested in maintaining a personalized version of a skin without missing out on future updates. It can also be used to avoid having to download a repository repeatedly just to add new features.
1. SIGN-UP FOR A GITHUB ACCOUNT
https://github.com/join
A GitHub account is required to fork a repository and rebrand it as your own. This sign-in also carries-over to GitHub Desktop.
2. DOWNLOAD GITHUB DESKTOP
https://windows.github.com/
GitHub Desktop provides a desktop interface to manage your skin. A few antiquated command prompt entries remain necessary to keep up-to-date with the original repository, but this program will make working with GitHub a user-friendly experience. Here, you can keep track of and authorize new commits and sync these changes with your online GitHub account.
3. FORK A REPOSITORY
To fork a repository, navigate to the GitHub page of your favorite skin and click the Fork button. An identical copy of the skin will be created with your GitHub moniker as the new lead designer. Any alterations of this repository can be of your own creation. While future changes to the original repository can also be mirrored/synced with your new fork:
The forked repository should bear the name of the GitHub account owner:
4. CLONE THE REPOSITORY TO THE DESKTOP
Once the skin has been forked, click Clone in Desktop to create a copy of the forked repository in GitHub Desktop (choose GitHub). The program will ask you to select a folder for the skin to be copied. It can be convenient to place this folder in Kodi addons so downloaded changes are reflected immediately in the active skin (e.g. C:\Users\USERNAME\AppData\Roaming\Kodi\addons). The existing skin folder must first be deleted for the GitHub fork to take its place. Others may prefer to keep the GitHub folder separate from the active skin to avoid overwriting and losing local versions.
When making changes locally, adding files to the chosen folder location will be tracked and uploaded as new commits to your skin:
So, you may want to test a new feature by changing a skin xml file in the userdata folder and loading Kodi. Once satisfied with the change, as long as the xml is in your GitHub folder, opening GitHub Desktop will prepare a new commit. The program will display the additions or subtractions to the code and await confirmation of the change. This commit can then be synced to the online GitHub account.
5. REMAINING SYNCED WITH THE ORIGINAL REPOSITORY
You will likely want to keep up with future commits from the original repository including fixes and new features. Downloading updates is possible by syncing the fork with the original. To accomplish this, the upstream (original) repository must first be declared in Git Shell.
Right-click the repository in GitHub Desktop and choose Open in Git Shell:
Git Shell command prompt:
Step 1 – Add Upstream Repository
In this example, the upstream repository is Aeon Nox 5.
Type: git remote add upstream https://github.com/BigNoid/Aeon-Nox
The upstream repository is added.
Step 2 – Fetch Upstream Branches
To load remote branches before syncing, it is necessary to fetch this information from the remote server.
Type: git fetch upstream
Changes from all remote branches are loaded.
Step 3 – Sync Changes with the Forked Repository
Close Git Shell and return to GitHub Desktop. You should now be presented with an option to update the current branch with the selected remote branch. Be careful when updating from this screen by ensuring the correct paths are chosen. The example below shows two choices are required before updating:
Top: Choose Local Branch (e.g. master)
Black: Choose Remote Branch (e.g. ORIGINAL/master)
After selecting the desired branches, click Update to download files from the remote server.
Changes from the original repository are synced to the fork. In this case, synced changes come from the master branch.
Opening GitHub Desktop will show the new commits on the fork's timeline. Local files in the GitHub folder are updated. Sync all local changes to the server.
Alternative – Update with Git Shell
It is possible to manually apply updates using Git Shell with the commands below:
git fetch upstream
Changes from the upstream (forked repository) are loaded.
git merge upstream/branch
The local branch is synced to the desired remote branch. For example, git merge upstream/master would download changes from the remote master branch.
6. DEALING WITH MERGE CONFLICTS
Merge conflicts may arise during merges with the original repository if common code is in conflict. These files can be ignored or edited manually at the discretion of the user. The more one edits a fork, the more likely merge conflicts will arise. If you are merely syncing with an online repository and not editing any files on your own, then merge conflicts will be unlikely.
Discarding Changes to Conflicting Files
In this example, conflicting files will be discarded to allow the sync to be completed. A commit should be loaded after attempting a sync with the remote branch. This is an extra commit on top of those downloaded from the main branch, which provides a summary of all files involved including those in conflict.
Any file not checked by default is in conflict. The code on the right clearly indicates where code conflicts are apparent. Any commit attempted with these conflicts will be rejected.
The recommendation is to right-click each conflict and select Discard Changes. These commits will be dealt with manually:
Add Changes Marked as Conflicts as Manual Edits
Open the original repository and click the commit button in the top-left corner:
A list of commits will be loaded. Choose the commit with the conflicting file and open the same file in Notepad++ or another xml editor. Add each desired change to the xml. This can mean hunting down line numbers and cutting and pasting text. It may be easiest to download the file from the original repository and paste the changes from downloaded file:
Create a New Commit
When finished, close the file and return to GitHub Desktop. The program should detect the edited file and ready a new commit. Commit to master and Sync the changes to the Web:
That's it! Rinse and repeat as desired. With a combination of GitHub, GitHub Desktop and Git Shell, you can enjoy editing and maintaining your very own custom Kodi skin.
FURTHER READING
https://processwire.com/talk/topic/1565-...r-windows/
SKINNING TIP
Add ReloadSkin() to your keyboard.xml to allow instant loading of your skinning changes in Kodi. This is a major time saver!
*Alternative approach using tortoisegit.
This is a detailed tutorial on how to fork a GitHub repository and keep it in-sync with the original branch. This should be of particular interest to those interested in maintaining a personalized version of a skin without missing out on future updates. It can also be used to avoid having to download a repository repeatedly just to add new features.
1. SIGN-UP FOR A GITHUB ACCOUNT
https://github.com/join
A GitHub account is required to fork a repository and rebrand it as your own. This sign-in also carries-over to GitHub Desktop.
2. DOWNLOAD GITHUB DESKTOP
https://windows.github.com/
GitHub Desktop provides a desktop interface to manage your skin. A few antiquated command prompt entries remain necessary to keep up-to-date with the original repository, but this program will make working with GitHub a user-friendly experience. Here, you can keep track of and authorize new commits and sync these changes with your online GitHub account.
3. FORK A REPOSITORY
To fork a repository, navigate to the GitHub page of your favorite skin and click the Fork button. An identical copy of the skin will be created with your GitHub moniker as the new lead designer. Any alterations of this repository can be of your own creation. While future changes to the original repository can also be mirrored/synced with your new fork:
The forked repository should bear the name of the GitHub account owner:
4. CLONE THE REPOSITORY TO THE DESKTOP
Once the skin has been forked, click Clone in Desktop to create a copy of the forked repository in GitHub Desktop (choose GitHub). The program will ask you to select a folder for the skin to be copied. It can be convenient to place this folder in Kodi addons so downloaded changes are reflected immediately in the active skin (e.g. C:\Users\USERNAME\AppData\Roaming\Kodi\addons). The existing skin folder must first be deleted for the GitHub fork to take its place. Others may prefer to keep the GitHub folder separate from the active skin to avoid overwriting and losing local versions.
When making changes locally, adding files to the chosen folder location will be tracked and uploaded as new commits to your skin:
So, you may want to test a new feature by changing a skin xml file in the userdata folder and loading Kodi. Once satisfied with the change, as long as the xml is in your GitHub folder, opening GitHub Desktop will prepare a new commit. The program will display the additions or subtractions to the code and await confirmation of the change. This commit can then be synced to the online GitHub account.
5. REMAINING SYNCED WITH THE ORIGINAL REPOSITORY
You will likely want to keep up with future commits from the original repository including fixes and new features. Downloading updates is possible by syncing the fork with the original. To accomplish this, the upstream (original) repository must first be declared in Git Shell.
Right-click the repository in GitHub Desktop and choose Open in Git Shell:
Git Shell command prompt:
Step 1 – Add Upstream Repository
In this example, the upstream repository is Aeon Nox 5.
Type: git remote add upstream https://github.com/BigNoid/Aeon-Nox
The upstream repository is added.
Step 2 – Fetch Upstream Branches
To load remote branches before syncing, it is necessary to fetch this information from the remote server.
Type: git fetch upstream
Changes from all remote branches are loaded.
Step 3 – Sync Changes with the Forked Repository
Close Git Shell and return to GitHub Desktop. You should now be presented with an option to update the current branch with the selected remote branch. Be careful when updating from this screen by ensuring the correct paths are chosen. The example below shows two choices are required before updating:
Top: Choose Local Branch (e.g. master)
Black: Choose Remote Branch (e.g. ORIGINAL/master)
After selecting the desired branches, click Update to download files from the remote server.
Changes from the original repository are synced to the fork. In this case, synced changes come from the master branch.
Opening GitHub Desktop will show the new commits on the fork's timeline. Local files in the GitHub folder are updated. Sync all local changes to the server.
Alternative – Update with Git Shell
It is possible to manually apply updates using Git Shell with the commands below:
git fetch upstream
Changes from the upstream (forked repository) are loaded.
git merge upstream/branch
The local branch is synced to the desired remote branch. For example, git merge upstream/master would download changes from the remote master branch.
6. DEALING WITH MERGE CONFLICTS
Merge conflicts may arise during merges with the original repository if common code is in conflict. These files can be ignored or edited manually at the discretion of the user. The more one edits a fork, the more likely merge conflicts will arise. If you are merely syncing with an online repository and not editing any files on your own, then merge conflicts will be unlikely.
Discarding Changes to Conflicting Files
In this example, conflicting files will be discarded to allow the sync to be completed. A commit should be loaded after attempting a sync with the remote branch. This is an extra commit on top of those downloaded from the main branch, which provides a summary of all files involved including those in conflict.
Any file not checked by default is in conflict. The code on the right clearly indicates where code conflicts are apparent. Any commit attempted with these conflicts will be rejected.
The recommendation is to right-click each conflict and select Discard Changes. These commits will be dealt with manually:
Add Changes Marked as Conflicts as Manual Edits
Open the original repository and click the commit button in the top-left corner:
A list of commits will be loaded. Choose the commit with the conflicting file and open the same file in Notepad++ or another xml editor. Add each desired change to the xml. This can mean hunting down line numbers and cutting and pasting text. It may be easiest to download the file from the original repository and paste the changes from downloaded file:
Create a New Commit
When finished, close the file and return to GitHub Desktop. The program should detect the edited file and ready a new commit. Commit to master and Sync the changes to the Web:
That's it! Rinse and repeat as desired. With a combination of GitHub, GitHub Desktop and Git Shell, you can enjoy editing and maintaining your very own custom Kodi skin.
FURTHER READING
https://processwire.com/talk/topic/1565-...r-windows/
SKINNING TIP
Add ReloadSkin() to your keyboard.xml to allow instant loading of your skinning changes in Kodi. This is a major time saver!