phpBB

Development Wiki

Difference between revisions of "Working with Git"

From phpBB Development Wiki

(Further reading: adding git for the lazy)
(External links: TortoiseGIT -> TortoiseGit)
Line 128: Line 128:
 
* [http://github.com/ GitHub]
 
* [http://github.com/ GitHub]
 
* [http://github.com/phpbb phpBB GitHub account]
 
* [http://github.com/phpbb phpBB GitHub account]
* [http://code.google.com/p/tortoisegit/ TortoiseGIT] - A windows Git client based on TortoiseSVN
+
* [http://code.google.com/p/tortoisegit/ TortoiseGit] - A windows Git client based on TortoiseSVN
  
 
[[Category:Development|Git]]
 
[[Category:Development|Git]]
 
[[Category:Tutorials]]
 
[[Category:Tutorials]]

Revision as of 21:55, 7 March 2010

This gives some documentation on using git for phpBB development, details of the phpBB git infrastructure documents the repositories and branches available for use.

Command Line

Basics

Cloning

Clone the main phpBB3 repository.

git clone git://github.com/phpbb/phpbb3.git

Branches

See phpBB3 Branches

Developers

Developers should fork a copy of the repository on GitHub from [1] and then clone as instructed by GitHub.

Configuration

  • E-mail address:
    git config --add user.email username@phpbb.com
  • Add the upstream remote (you can change 'upstream' to whatever you like):
    git remote add upstream git://github.com/phpbb/phpbb3.git

Creating local branches

To work on phpBB you need to create local branches of whichever develop branches you need, issue the following command to perform this operation:

git checkout -b develop origin/develop

Workflows

Pulling in upstream changes

You will need to merge in changes made to the upstream repository for them to appear in your fork, the steps to do this follow. I'm assuming you are performing this on the develop branch, but it could be a bug fix branch or a develop release branch, so ensure you are on the correct branch using git branch and change with git checkout if required.

  1. Pull the changes from the upstream develop branch:
    git pull upstream develop
  2. Push the changes back to your fork (substitute develop for the current branch):
    git push origin develop

The following image visualises the phpBB 3 branching model. It may help to understand the different branches this section refers to later.

Error creating thumbnail: Unable to save thumbnail to destination

View in large or as svg.

Bug fixing

Ensure you are using the correct develop branch first and not a master branch. In this example we are using develop-olympus.

  1. git checkout develop-olympus # Checkout the base branch
  2. git branch bug/12345 # Create a new branch for your bug fix
  3. git checkout bug/12345 # Switch to the new branch
  4. Make your changes
  5. git add <files> # Stage the files
  6. git commit # Commit staged files - please use a correct commit message: Git Commit Messages
  7. Make more changes & commits if necessary
  8. git push origin bug/12345 # Push the branch back to github

Starting a new feature

Ensure you are using the correct develop branch first and not a master branch. In this example we are using develop.

  1. git checkout develop # Checkout the base branch
  2. git checkout -b feature/my-fancy-new-feature # Create a new branch for your feature & switch to it
  3. Make your changes
  4. git add <files> # Stage the files
  5. git commit # Commit staged files - please use a correct commit message: Git Commit Messages
  6. Make more changes & commits
  7. git push origin feature/my-fancy-new-feature # Push the branch back to github

Collaborating with other developers on a feature

You have pushed a new feature to github and another developer has worked on it. This is how you can integrate their changes into your own feature branch.

  1. git remote add otherdeveloper git://github.com/otherdeveloper/phpbb3.git # Add the other developer's repository as a remote
  2. git fetch otherdeveloper # Fetch otherdeveloper's changes
  3. git checkout feature/my-fancy-new-feature # Switch to the feature branch
  4. git merge otherdeveloper/feature/my-fancy-new-feature # Merge otherdeveloper's changes into your feature branch
  5. If necessary resolve conflicts & commit
  6. git push origin feature/my-fancy-new-feature # Push the branch back to github

Merging a feature or bugfix branch

Once a feature or bugfix is complete it can be merged back into the develop branch. To preserve history we never fast forward such merges. In this example we will merge the bugfix created earlier into develop-olympus. We then merge the changes into develop to keep that branch up to date.

  1. git checkout develop-olympus # Branch we want to merge into
  2. git merge --no-ff bug/12345 # Merge, but do not fast forward
  3. git branch -d bug/12345 # Delete the bugfix branch
  4. git checkout develop # Switch to develop
  5. git merge --no-ff develop-olympus # Merge to keep the develop branches in sync
  6. git push origin develop-olympus # Push the develop-olympus branch back to github
  7. git push origin develop # Push the develop-olympus branch back to github
  8. git push origin :bug/12345 # Remove the bug fix branch from github

Windows

Quick info for those with TortoiseGit (and used to working with TortoiseSVN)

Create your own SSH key

http://help.github.com/msysgit-key-setup/

TortoiseGit will automatically use the SSH key

Note: I used the OpenSSH option during installation, so I am not sure if this works for the other option or if you are supposed to do it some other way

Clone

Then simply clone the repository to your local system and the rest is mostly like TortoiseSVN.

Commands

Pull
Grab the updates from upstream
Commit
Commits the changes locally (you must Push or Sync to commit the changes to the repository)
Push
Pushes the changes that were locally made into the repository
Sync
Pushes/Pulls changes with more options

Further reading

External links