Win HOW TO - Clone/Fork a GitHub Repository and Remain Synced with the Original
#1
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:

Image

The forked repository should bear the name of the GitHub account owner:

Image

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:

Image

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:

Image

Git Shell command prompt:

Image

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

Image

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

Image

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.

Image

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:

Image

Add Changes Marked as Conflicts as Manual Edits

Open the original repository and click the commit button in the top-left corner:

Image

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:

Image

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:

Image

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!
Reply
#2
Nice! Small comment; instead of
Code:
git merge upstream/master
do
Code:
git rebase upstream/master
to avoid merge commits.
Reply
#3
7. CREATING A NEW BRANCH

1. Choose the existing branch from which the new branch will be based.
  • e.g. master

2. Click on the Y-shaped branch icon in the top-left corner. Type the desired name of the new branch and select Create new branch.
  • e.g. isengard

Image

3. Click Publish to publish and sync the new branch to the server.

Image

4. Future updates to this branch would be made as follows:
  • Select the branch to sync locally in GitHub Desktop (e.g. isengard). This will change the composition of the files in the GitHub folder;
  • Insert local files into the GitHub folder and create a new commit.
OR
  • Select the local branch to be synced in GitHub Desktop (e.g. isengard);
  • Select the remote branch to download changes in GitHub Desktop (e.g. BigNoid/isengard);
  • Click Update to merge with the desired branch.

Sync all local changes to the server.

Note: All synchronization is dependent upon the active branch selected in GitHub Desktop. Changing branches changes the content of the files in the GitHub folder. So only one branch can be active and edited at any time.
Reply
#4
8. USING TORTOISEGIT FOR EASY SYNCING

If a detailed summary of each commit is unnecessary and you are simply wanting to remain synced with an online repository without forking it, tortoisegit may be what you are after.

Install:
1. Clone the Repository

The cloned repository should be placed in the Kodi addons folder with all other active Kodi addons.
e.g. C:\Users\USERNAME\AppData\Roaming\Kodi\addons

Right-click on an empty space in the addons folder and select Git Clone...

Image

Enter the URL of the repository in the top address bar:

Image

The repository will be cloned to the addons folder. This may take some time depending on the size of the repository.

2. Sync the Downloaded Repository with the Original

Right-click on the folder of the cloned repository and select Git Sync...

Image

A menu will pop-up. From here, it is possible to select what Local Branch will be updated from the chosen Remote Branch of the original repository.

Two commands are of use:

Fetch: Loads a list of the most recent commits from the selected Remote Branch.

Image

Pull: Completes a local sync of all changed files from the selected Remote Branch.

Image

3. Change & Add New Branches

Git Clone downloads the master branch by default. To switch to additional branches, Right-click on the folder of the cloned repository and select TortoiseGit -> Switch/Checkout...

Image

Choose the branch and leave the checkbox Create New Branch ticked. The contents of the folder in Kodi addons will be changed to reflect the new branch.

Image

Switching between branches is possible with the context menu.

4. Resolving Merge Conflicts

During the process of switching branches and merging, it is possible to encounter merge conflicts where tortoisegit is unable to merge changed files due to code conflicts. These exceptions must be dealt with separately. If not, Git Sync... will be unavailable until conflicts are resolved.

After the Pull request, problem files will be highlighted in red in the Conflicts tab. These files have common code incapable of being updated because the line numbers of each document are in conflict:

Image

To correct this, Right-click on the folder of the cloned repository and select TortoiseGit -> Resolve...

Image

The recommendation here is to download the actual files from the online branch (e.g. master) and replace each in the tortoisegit clone folder. This will ensure all recent changes are included in the merge. Alternatively, you could open each file in conflict and edit each change manually.

When all files are edited/replaced, Select all and choose Ok.

Image

The program will prompt you to submit a new commit. Select Commit...

The conflicting files are ignored and the merge is completed.

Image

Note: The Resolve command does not really resolve the conflict. It uses "git add" to mark file status as resolved to allow you to commit your changes and it removes the filename.ext.BASE.ext, filename.ext.LOCAL.ext and filename.ext.REMOTE.ext files.

If the merge was completed successfully, the folder should display a green checkmark. This indicates Git Sync... is available once again:

Image
Reply
#5
(2015-06-13, 12:11)BigNoid Wrote: Nice! Small comment; instead of
Code:
git merge upstream/master
do
Code:
git rebase upstream/master
to avoid merge commits.

I returned to git merge upstream/master because git rebase upstream/master was giving me a detached head error -- not syncing to the correct branch.

git rebase --abort was required to cancel this error.

git commit --amend is also useful for undoing the last commit.

git merge --abort can be used to abort a merge in-progress.
Reply
#6
all I want to do is automatically update the MADNOX skin with new updates.
I am not a computer expert.
I tried your instructions by installing GIT and tortoise in section 8 above but when I right click on empty space I do not see GIT Clone.

I get GIT commit Master and Tortoise.
I dunno how to paste images here.
please any help will be appreciated.
Regards,

PJ
Reply
#7
(2016-03-03, 10:04)P_Jamula Wrote: all I want to do is automatically update the MADNOX skin with new updates.
I am not a computer expert.
I tried your instructions by installing GIT and tortoise in section 8 above but when I right click on empty space I do not see GIT Clone.

I get GIT commit Master and Tortoise.
I dunno how to paste images here.
please any help will be appreciated.

Did you install Git for Windows?

Try opening Tortoisegit from Program Files and attempt to clone from there.
Reply
#8
(2016-03-03, 22:47)Warner306 Wrote: Did you install Git for Windows?

Try opening Tortoisegit from Program Files and attempt to clone from there.

Thanks for the response...

yes GIT for windows...
in program files many exe's for tortoise ... none for clone... really lost here.

just a thought when installing GIT what options should I have used? maybe some of my choices could have been the wrong ones.
Regards,

PJ
Reply
#9
(2016-03-04, 03:45)P_Jamula Wrote:
(2016-03-03, 22:47)Warner306 Wrote: Did you install Git for Windows?

Try opening Tortoisegit from Program Files and attempt to clone from there.

Thanks for the response...

yes GIT for windows...
in program files many exe's for tortoise ... none for clone... really lost here.

just a thought when installing GIT what options should I have used? maybe some of my choices could have been the wrong ones.

I'll have to open the program myself to be of further help.
Reply
#10
(2016-03-04, 05:27)Warner306 Wrote: I'll have to open the program myself to be of further help.

OK i'll wait for your assistance...
thanks a lot
Regards,

PJ
Reply
#11
(2016-03-04, 13:39)P_Jamula Wrote:
(2016-03-04, 05:27)Warner306 Wrote: I'll have to open the program myself to be of further help.

OK i'll wait for your assistance...
thanks a lot

I sent you a PM describing how to use Git for Windows (using the Git GUI) to clone an online repository. Updates to the cloned folder should work as described in this guide.
Reply

Logout Mark Read Team Forum Stats Members Help
HOW TO - Clone/Fork a GitHub Repository and Remain Synced with the Original2