Updated 047 Tutorial on forking JCB snippets so you can share your snippets with the rest of the Community (markdown)

Amigo 2019-08-29 15:37:32 +02:00
parent 3e2a16ad1b
commit 0f5be6a70d

@ -71,7 +71,7 @@ This brings us to those three values that must always be set and should not chan
[00:13:23](https://www.youtube.com/watch?v=0hgHeQVTLOk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h13m23s)
When a snippet is added, it should be added to the correct Library and Type and from the start given the correct Name so that it is not necessary to change those three again. Most of the time our pull request will be rejected because this will mess up many conventions and cause many duplicates across the system in other developers' environment when they import this new snippet. Save and close.
When a snippet is added, it should be added to the correct Library and Type and from the start given the correct Name so that it is not necessary to change those three again. Most of the time our pull request will be rejected because this will mess up many conventions and cause many duplicates across the system in other developers' environments when they import this new snippet. Save and close.
### Adding A New Snippet
@ -126,27 +126,23 @@ Now we want to add the Accordion which is the new snippet. It is just `git add`
[00:28:03](https://www.youtube.com/watch?v=0hgHeQVTLOk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h28m03s)
This is where we want to do a few more things to your Forked and therefore cloned repository. We want to do something that will keep your repository in sync with the upstream. I'm just going to go and Google this quickly. This is a very helpful document. [00:28:31](https://www.youtube.com/watch?v=0hgHeQVTLOk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h28m31s) We first need to do this configuring a remote that points to an upstream repository. Let's first look at that one. So this gives you a little explanation of what you should do. First: 'List the current configured remote repository for your fork'.(`$ git remote`) [00:28:56](https://www.youtube.com/watch?v=0hgHeQVTLOk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h28m56s) With that done, it shows this `git` or the `origin` and it's the `fetched` and the `pushed` remote branches. It's going to say: 'Specify a new remote upstream repository that will be synced with the fork'. We'll use the original owner and the original repository name which in our case is the following. The original owner is [00:29:28](https://www.youtube.com/watch?v=0hgHeQVTLOk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h29m28s) 'vdm.io' and the repository is 'Joomla-Component-Builder'. To get that name, you could come here(Green Clone Button) and you could get the name `vdm.io/Joomla-Component-Builder`. [00:29:48](https://www.youtube.com/watch?v=0hgHeQVTLOk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h29m48s) Copy the name. Going back to our tutorial. We will type the git and I suppose you will have to get the HTTPS version since you will not have permission to work with the SSH version. Let's get the HTTPS one which means that you should click HTTPS here and then grab that version, copy it and [00:30:16](https://www.youtube.com/watch?v=0hgHeQVTLOk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h30m16s) _control shift v_ will paste it in, into the command line or some command lines even gives you this option to paste with a mouse. Okay, so now we got that there and press enter. [00:30:37](https://www.youtube.com/watch?v=0hgHeQVTLOk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h30m37s) I didn't add remote add so it was looking for a file. If we did that version we'll see it has this `upstream` there as well. That was just to add the remote or the upstream repository to the cloned version.<<<<<<<<<
This is where we want to do a few more things to your Forked and therefore cloned repository. We want to do something that will keep your repository in sync with the upstream. I'm just going to go and Google this quickly. This is a very helpful document. [00:28:31](https://www.youtube.com/watch?v=0hgHeQVTLOk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h28m31s) We first need to do this configuring a remote that points to an upstream repository. Let's first look at that one. So this gives you a little explanation of what you should do. First: 'List the current configured remote repository for your fork'.(`$ git remote`) [00:28:56](https://www.youtube.com/watch?v=0hgHeQVTLOk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h28m56s) With that done, it shows this `git` or the `origin` and it's the `fetched` and the `pushed` remote branches. It's going to say: 'Specify a new remote upstream repository that will be synced with the fork'. We'll use the original owner and the original repository name which in our case is the following. The original owner is [00:29:28](https://www.youtube.com/watch?v=0hgHeQVTLOk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h29m28s) 'vdm.io' and the repository is 'Joomla-Component-Builder'. To get that name, you could come here(Green Clone Button) and you could get the name `vdm.io/Joomla-Component-Builder`. [00:29:48](https://www.youtube.com/watch?v=0hgHeQVTLOk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h29m48s) Copy the name. Going back to our tutorial. We will type the git and I suppose you will have to get the HTTPS version since you will not have permission to work with the SSH version. Let's get the HTTPS one which means that you should click HTTPS here and then grab that version, copy it and [00:30:16](https://www.youtube.com/watch?v=0hgHeQVTLOk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h30m16s) _control shift v_ will paste it in, into the command line or some command lines even gives you this option to paste with a mouse. Okay, so now we got that there and press enter. [00:30:37](https://www.youtube.com/watch?v=0hgHeQVTLOk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h30m37s) I didn't add remote add so it was looking for a file. If we did that version we'll see it has this `upstream` there as well. That was just to add the remote or the upstream repository to the cloned version.
### Syncing A Fork (See Video)
[00:31:01](https://www.youtube.com/watch?v=0hgHeQVTLOk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h31m01s)
Now let's go see how to keep it in sync. It says that you would open the terminal and you would do git fetch upstream. It will pull down this and make sure that there is a branch called upstream master. Then you would check out the master and switch to the master branch and do merge upstream master. Which if while you were busy doing the snippets improvements and things [00:31:30](https://www.youtube.com/watch?v=0hgHeQVTLOk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h31m30s) and there's been commits to the master branch, you want to make sure that before pushing all this upstream, before making a pull request, that you first merge the already changes from the master branch into your branch and then make your commits on top of that. This will help to avoid not having specific commits in your branch. I know it gets a little bit complicated [00:32:01](https://www.youtube.com/watch?v=0hgHeQVTLOk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h32m01s) but if you get stuck, we will most of the times be able to help you figure this out again. But like I explained, in the beginning, to know how to work with git Is your responsibility so that when you are wanting to share with the community snippets. [00:32:23](https://www.youtube.com/watch?v=0hgHeQVTLOk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h32m23s) You must know how to merge your upstream with your master branch and ensure that you are up-to-date with that before making a push to your branch. I hope you understand. If you don't please Google it and do some homework to get your Git knowledge all freshened up and ready. I know we didn't make any changes to the master branch during this tutorial.
How to keep it in sync. It says that you would open the terminal and you would do `$ git fetch upstream`. It will pull down this and make sure that there is a branch called `upstream master`. Then you would check out the master and switch to the master branch and do `$ git merge upstream/master` which if you were busy doing the snippets, improvements and things [00:31:30](https://www.youtube.com/watch?v=0hgHeQVTLOk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h31m30s) and there has been commits to the master branch, you need to make sure that before pushing all this upstream, and before making a pull request, that you have first merged the changes from the master branch into your branch and then make your commits on top of that. This will avoid having non-specific commits in your branch. [00:32:01](https://www.youtube.com/watch?v=0hgHeQVTLOk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h32m01s) If you get stuck, we will most of the times be able to help you figure this out. But like I explained, in the beginning, when you want to share snippets with the community you should know how to work with Git [00:32:23](https://www.youtube.com/watch?v=0hgHeQVTLOk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h32m23s) and know how to merge your upstream with your master branch and ensure that you are up-to-date with that before making a push to your branch.
### Git fetch upstream - Git checkout master - Git merge upstream master
[00:32:56](https://www.youtube.com/watch?v=0hgHeQVTLOk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h32m56s)
### git fetch upstream - git checkout master - git merge upstream master
No changes to the master branch had been done during this tutorial. I will demonstrate the process of `git fetch upstream`. Since we did not make any changes, there would not be any great fireworks. Perhaps some of you will experience it a little different [00:33:22](https://www.youtube.com/watch?v=0hgHeQVTLOk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h33m22s) especially if there have been changes to the upstream while you were busy working. `git checkout master` is usually the branch that you are on but just to make sure you are already on the master branch, type `git merge upstream master`. It indicates like now that it is `already up to date`. If it was not, it will merge those two branches with the changes you have made. <<<<
[00:32:56](https://www.youtube.com/watch?v=0hgHeQVTLOk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h32m56s)
I can demonstrate the process of git fetch upstream and it will do that. But since I know that we didn't make any changes, at the end of the day we will not be seeing any great fireworks happening right now. I suppose some of you will experience it a little different [00:33:22](https://www.youtube.com/watch?v=0hgHeQVTLOk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h33m22s) especially if there have been changes to the upstream while you have been working. git checkout master is usually the branch that you're on but just to make sure you're already on the master branch. Then git merge upstream master. [00:33:44](https://www.youtube.com/watch?v=0hgHeQVTLOk&list=PLQRGFI8XZ_wtGvPQZWBfD[00:28:06](https://www.youtube.com/watch?v=0hgHeQVTLOk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h28m06s)zzlERLQgpMRE&t=00h33m44s) It says like now it's already up to date. If it wasn't it will merge those two branches with the changes you've made.
### git push - Everything You've Done Gets Pushed To Your Cloned Version On GitHub