Difference between revisions of "HOW-TO check out PKP applications from git"

From PKP Wiki
Jump to: navigation, search
(Use tracking branches for development)
m (Check out the application(s) on your local machine)
(47 intermediate revisions by 7 users not shown)
Line 1: Line 1:
 
= Intro =
 
= Intro =
  
This is the official process to check out OMP with the PKP library as a sub-module.
+
This is the official process to check out OMP with the PKP library as a sub-module. The same process applies to all other PKP projects. Just exchange omp for ojs, ocs or harvester.
  
 
= Create github.com user =
 
= Create github.com user =
  
Go to github.com and create a user account. Log in to your user account.
+
This tutorial assumes that you'll work with forked copies of our software on github and that you intend to publish your changes back. You can do without forks, especially if you want to have only read access. You'll have to adapt this process a bit then (e.g. exchange the read/write URLs to forks with read-only URLs to the master repository). Please refer to the git documentation for this.
 +
 
 +
If you want write access to the repository then go to github.com and create your own user account there and log into it. See the [http://help.github.com/key-setup-redirect/ github documentation] to generate/add your RSA key to your github account.
 +
 
 +
If you want to write back to the official PKP git repositories then you'll need write access there. Please ask Juan or Florian to grant you access.
  
 
= Delete existing personal forks =
 
= Delete existing personal forks =
  
First you have to delete existing personal forks of omp/pkp-lib if you have cloned these repositories before. You obviously shouldn't do this when there are still changes in there you don't have in other locations!
+
First you have to delete existing personal forks of omp/pkp-lib if you have cloned these repositories before. You obviously shouldn't do this when there are still changes in there you don't have in other locations! If you don't have existing forks then you can jump to the next step.
 +
 
 +
Otherwise do the following:
  
 
* Go to your personal github dashboard.
 
* Go to your personal github dashboard.
Line 17: Line 23:
 
* Repeat these steps for both omp and pkp-lib
 
* Repeat these steps for both omp and pkp-lib
  
= Fork the official omp/pkp-lib repositories =
+
= Fork the official application repositories =
  
 
* Go to http://github.com/pkp/omp and fork it.
 
* Go to http://github.com/pkp/omp and fork it.
Line 25: Line 31:
 
* Go to http://github.com/pkp/harvester and fork it.
 
* Go to http://github.com/pkp/harvester and fork it.
  
= Clone your personal omp locally =
+
You can fork a subset of these projects if you do not intend to work on all of them. You'll always need the pkp-lib repository together with any of the application-specific repositories.
  
Please replace "your-pkp-workspace" and "your-user" with the appropriate values.
+
= Check out the application(s) on your local machine =
  
 +
Use the shell script [[Media:Checkout.sh.txt|checkout.sh]] to check out each application that you wish to work on:
 
<pre>
 
<pre>
cd ~/your-pkp-workspace
+
bash checkout.sh.txt your-user ojs ojs-checkout
git clone git@github.com:your-user/omp.git omp
+
 
</pre>
 
</pre>
 +
In the above example, "your-user" is your github.com username. It will check the "ojs" application out into a directory called "ojs-checkout".
  
= Set up pkp submodule in your local omp clone =
+
= Where to go from here? =
 
+
<pre>
+
cd omp/
+
git submodule init
+
</pre>
+
 
+
edit .git/config with your favourite editor and find (or add if it's not there):
+
<pre>
+
[submodule "lib/pkp"]
+
        url = git@github.com:pkp/pkp-lib
+
</pre>
+
 
+
Change the url to    
+
<pre>
+
        url = git@github.com:your-user/pkp-lib.git
+
</pre>
+
 
+
Execute:
+
<pre>
+
git submodule update
+
cd lib/pkp/
+
git checkout master
+
cd ../..
+
</pre>
+
 
+
= Add the official repository =
+
 
+
The 'official' respositories can be compared to the role that PKP's old CVS repositories used to fill.  Adding the official branch allows you to synchronize your code with the rest of the team, and should be pulled from before creating a patch or making a commit.
+
 
+
Execute:
+
<pre>
+
cd lib/pkp/
+
git remote add official git://github.com/pkp/pkp-lib.git
+
git checkout -b master official/master
+
cd ../..
+
git remote add official git://github.com/pkp/omp.git
+
git checkout -b master official/master
+
</pre>
+
 
+
= Create development branches =
+
 
+
Create development branches in the main project and the sub-module. I'll use the branch "dev" here but this is arbitrary. The branch name should represent the development topic you intend to work on.
+
 
+
<pre>
+
git checkout -b dev official/master
+
cd lib/pkp/
+
git checkout -b dev official/master
+
cd ../..
+
</pre>
+
 
+
Never develop directly on the master branch. We use the master branch to track released code and tested changes.
+
 
+
= Start pulling changes =
+
 
+
Now you can start pulling in changes from other people's repositories. The following is just an example. See for yourself what others are working on and pull in what you need to get started.
+
 
+
<pre>
+
cd lib/pkp
+
git remote add juan \
+
              git://github.com/jalperin/pkp-lib.git
+
git pull juan modal
+
 
+
cd ../..
+
git remote add juan \
+
              git://github.com/jalperin/omp.git
+
git pull juan modal
+
</pre>
+
 
+
You may get merge conflicts, if the repository you pull from did not merge in all changes from CVS already. See man git-merge for more info on how to solve merge conflicts.  If you want to use another developer's code without merging it into your branch, you'll want to pull their branch onto a clean branch--Switch to the master branch (use 'git stash' if you have uncommitted changes you want to save) and create a fresh branch, e.g. execute:
+
 
+
<pre>
+
git stash save "Temporarily stashing code"
+
git checkout master
+
git pull official master
+
git checkout -b juanModal
+
git pull juan modal
+
......Play with Juan's code.......
+
git checkout modal
+
git stash pop
+
</pre>
+
 
+
= Make your own changes =
+
 
+
Make your own changes, publish them to your own repository for others to pull from
+
 
+
<pre>
+
touch my-new-file.tmp
+
git add my-new-file.tmp
+
git commit -m "added a useless file"
+
git push origin modal
+
</pre>
+
  
Use 'git status' liberally to give you information on what files will be in the next commit, which files are marked for deletion, etc. That's all. Enjoy developing PKP applications on git!
+
Have a look at [[frequent git use cases]] for typical git use cases you'll encounter in your day to day work with git.
  
 
= Resources =
 
= Resources =
  
 
[http://github.com/guides/git-cheat-sheet "Git cheat sheet"]
 
[http://github.com/guides/git-cheat-sheet "Git cheat sheet"]

Revision as of 13:20, 2 August 2013

Intro

This is the official process to check out OMP with the PKP library as a sub-module. The same process applies to all other PKP projects. Just exchange omp for ojs, ocs or harvester.

Create github.com user

This tutorial assumes that you'll work with forked copies of our software on github and that you intend to publish your changes back. You can do without forks, especially if you want to have only read access. You'll have to adapt this process a bit then (e.g. exchange the read/write URLs to forks with read-only URLs to the master repository). Please refer to the git documentation for this.

If you want write access to the repository then go to github.com and create your own user account there and log into it. See the github documentation to generate/add your RSA key to your github account.

If you want to write back to the official PKP git repositories then you'll need write access there. Please ask Juan or Florian to grant you access.

Delete existing personal forks

First you have to delete existing personal forks of omp/pkp-lib if you have cloned these repositories before. You obviously shouldn't do this when there are still changes in there you don't have in other locations! If you don't have existing forks then you can jump to the next step.

Otherwise do the following:

  • Go to your personal github dashboard.
  • In "Your Repositories" select the forks you want to delete.
  • Go to Admin tab.
  • Down on the page click on "Delete This Repository".
  • Repeat these steps for both omp and pkp-lib

Fork the official application repositories

You can fork a subset of these projects if you do not intend to work on all of them. You'll always need the pkp-lib repository together with any of the application-specific repositories.

Check out the application(s) on your local machine

Use the shell script checkout.sh to check out each application that you wish to work on:

bash checkout.sh.txt your-user ojs ojs-checkout

In the above example, "your-user" is your github.com username. It will check the "ojs" application out into a directory called "ojs-checkout".

Where to go from here?

Have a look at frequent git use cases for typical git use cases you'll encounter in your day to day work with git.

Resources

"Git cheat sheet"