Ok now that the EGit installation is complete is time to use to upload a project. So for starters its better to get good inside of GitHub working architecture. The first thing and one that was kind of hard for me to get is that we have a local repository and remote one. Now the tricky part is that we must always first make a commit to the local repository and only then you can push it to the remote one. What at first got me really confused is that in other SVN/CVS (like tortoise, which by the way O am not sure if still works like this been some years since last use it) systems you don't have to do this intermediary step. Once you've changed a file in you're local machine and you made a commit things woud go to the remote repository.
I took this schema from Wikipedia and it represents quite well what's going on in a git repository. First you create a project (your working directory) then you have to create a repository by command line or by EGit (will show this bellow). By creating a repository now you will have an extra folder which is maintained by Git (it's actually a .Git folder) and the block Index in the picture is an Head file in that folder. Now every time you make an add command the code/folders of your source will become staged, or a registry will be inserted in the Head file informing the changes you are about to do this way git keeps a track of your commits. Once you've done with staging you can commit by inserting a nice message on what you're actions were and finally push it to the remote server. The push will only be allowed your local repository is in sync with the remote one, so you might need to do a fetch command and check the differences and a pull to actually get those files that you don't have locally or that have been changed.
Maybe the first part would be better at the end I think you should re-read it after finishing the procedure. For the sake of completion I leave the images bellow on how to create the new project (standard Java on Eclipse...) to be under version control.
Now the EGit stuff comes into play, it is pretty straight forward wizard and allows to create the local repository. Pressing the second button over the project root folder on the Package Explorer window you should be able to see Team and a Share option inside it. This will open the wizard.
Select Git and on the next screen press create. This will show the folder where the repository will be created and the name you want to give to it.
Under the Project pane there is a checkbox if you leave it selected it will make that your working directory to be transferred to the repository folder.
In the end you should get a project with an question mark over it's files meaning there are unstaged changes.
If you have installed the GitHub command line mode installed and you can get it like this for Ubuntu.
$ apt-get install git-core
Or for other systems check it here
.
It is possible to check the repository by navigating there using the command line.
And you can see that there can be as many repositories as you want, also they can be connected to any number of online repos and even better you can have as many branches as you want (that will be another tutorial). So you can see from my Terminal that I am navigating to Git folder where I have all my local repos stored if I run a git status outside a repo the output will be error but as soon as you are inside a repo git command immediately starts to make sense of it.
Sem comentários:
Enviar um comentário