Cryto GIT commands and workflow

Workflow

The suggested workflow is the workflow described at http://nvie.com/posts/a-successful-git-branching-model/, with the following differences:

  • If you are developing something that you serve over a network (such as a web application), you may want to deploy your server(s) from the develop branch rather than the master branch, to ensure that new features become available early on.
  • Many Cryto projects will be projects that deal with rapidly evolving code and requirements. Rather than artificially hogging up the release process by enforcing a hotfix-only policy, you may want to allow small stand-alone feature additions into the master branch when they are not dependent on other features in the develop branch, more often tagging the master branch.

Creating a new repository

From scratch

git clone git@git.cryto.net projects/$username/$reponame
Variable Explanation
$username Your Cryto GIT username
$reponame The name of the new repository you want to create. This will be created in your working directory as a new folder, containing the actual repository contents.

Forking a different project

ssh git@git.cryto.net fork projects/$otheruser/$otherrepo projects/$username/$reponame
Variable Explanation
$otheruser Cryto GIT username of the user whose repository you want to fork
$otherrepo Name of the repository you want to fork
$username Your Cryto GIT username
$reponame The name of the new remote repository you want to create.

After forking the repository remotely, you can obtain a local copy of the repository by doing

git clone git@git.cryto.net projects/$username/$reponame

"Repository does not exist" error

Replacing the space between git.cryto.net and projects with a colon (:) fixes this.

git clone git@git.cryto.net:projects/$username/$reponame

Committing changes

GIT will only commit changes in files that you explicitly told it to watch. As such, you need to 'track' files before making a commit on a new file.

Add all (new) files in the repository to tracked files

git add -A

Commit all changes in tracked files

git commit -a -m "Your commit message goes here"

Pushing changes to your remote repository

First time

git push origin master

After that

git push

Working with branches

Creating or tracking a remote branch

When your project makes use of for example a develop branch, you'll need this to work with the same branches as other developers. Run it once for each branch you wish to work with. If the branch does not exist on the remote yet, it will be created and automatically tracked.

git checkout origin/$branch -b $branch
Variable Explanation
$branch The name of the branch you wish to create.

Creating a local branch

You will usually use this feature to create a local 'feature branch' - a branch that doesn't have to be in the remote repository, in which you develop a specific feature. Make sure you are switched to the branch you wish to branch off from (this will usually be develop). The following will create a new branch and switch to it.

git branch $branch
git checkout $branch
Variable Explanation
$branch The name of the branch you wish to create or track.

Pushing a local branch to the remote repository

If you've been working on a branch locally, and you decide to push it to the remote repository (so that, for example, other devs can collaborate on it with you), make sure you're in the local branch you wish to push, and do

git push origin $branch
Variable Explanation
$branch The name of the branch you wish to push.

Switching to a different branch in your repository directory

Don't forget to commit your changes before switching to a different branch!

git checkout $branch
Variable Explanation
$branch The name of the branch you wish to switch to.

Merging a branch

First, switch to the branch you want to merge into. Then run

git merge --no-ff $branch
Variable Explanation
$branch The branch that you wish to merge into the current branch.

Tagging a branch

You will usually be doing this when a new release version is merged into the master branch. Ensure you are in the master branch (or another correct branch, if you have a different usecase).

git tag -a $version
Variable Explanation
$version The version number you wish this release to have.
git/workflow.txt · Last modified: 2013/03/21 17:41 by shirokuma
Back to top
CC Attribution 3.0 Unported
Donate Valid CSS Driven by DokuWiki Recent changes RSS feed Valid XHTML 1.0