Developer Infos

From Netatalk Wiki
(Difference between revisions)
Jump to: navigation, search
Line 1: Line 1:
Cheatsheet "Working with git":
+
== Overview ==
  
 +
Netatalk source code is now hosted in a shared git repository to which only Netatalk Team members are allow to push to.
 +
 +
== Git Installation ==
 +
 +
* The git source code is available from [http://www.kernel.org/pub/software/scm/git/ http://www.kernel.org/pub/software/scm/git/].
 +
* The project home page is located at [http://git.or.cz/ http://git.or.cz/].
 +
* You should probably familiarize yourself with the [http://www.kernel.org/pub/software/scm/git/docs/gittutorial.html Git tutorial].
 +
 +
The examples in the following sections are based off of the tools and syntax used by git v1.5.3 or later.  Either apt-get, yum, or make install the tools.  See [http://www.kernel.org/pub/software/scm/git/ Git documentation] for more details on this part.
 +
 +
Note that under Debian or Ubuntu, git is distributed in the git-core package.  The git package contains the "GNU Interactive Tools".
 +
 +
 +
== Basic Netatalk Git ==
 +
 +
The master git repository is located at ''git://netatalk.git.sourceforge.net/gitroot/netatalk/netatalk''.  There is also a [http://netatalk.git.sourceforge.net/git/gitweb-index.cgi GitWeb installation].
 +
 +
Step Zero is to set your name and email address for commits:
 
<pre>
 
<pre>
$ git clone ssh://franklahm@netatalk.git.sourceforge.net/gitroot/netatalk/netatalk master
+
  $ git config --global user.email Your.Email@domain.com
$ git clone ssh://franklahm@netatalk.git.sourceforge.net/gitroot/netatalk/netatalk 2-1-branch
+
  $ git config --global user.name "Your Real Name"
$ cd 2-1-branch
+
$ git checkout --track origin/branch-netatalk-2-1
+
$ git commit ...
+
$ git push origin branch-netatalk-2-1
+
$ cd ../master
+
$ git pull
+
$ git merge --no-commit remotes/origin/branch-netatalk-2-1
+
$ git commit ...
+
 
</pre>
 
</pre>
 +
Next, clone the repository:
 +
<pre>
 +
  $ git clone git://netatalk.git.sourceforge.net/gitroot/netatalk/netatalk
 +
...
 +
  $ cd netatalk
 +
</pre>
 +
 +
List local  and remote branches:
 +
<pre>
 +
  $ git branch
 +
    * master
 +
 +
  $ git branch -r
 +
  origin/HEAD -> origin/master
 +
  origin/branch-1-5-prep
 +
  origin/branch-allea
 +
  origin/branch-aurp
 +
  origin/branch-compose-sp
 +
  origin/branch-netatalk-1-6
 +
  origin/branch-netatalk-2-0
 +
  origin/branch-netatalk-2-1
 +
  origin/branch-netatalk-2-2-0
 +
  origin/branch-netatalk-CNID-refactored
 +
  origin/branch-netatalk-afp-3x
 +
  origin/branch-netatalk-afp-3x-dev
 +
  origin/master
 +
  origin/origin
 +
  origin/vendor
 +
</pre>
 +
 +
Creating your own working branch from master:
 +
  $ git checkout -b my_branch origin/master
 +
  Branch my_branch set up to track remote branch refs/remotes/origin/master.
 +
  Switched to a new branch "my_branch"
 +
 +
Do your own local work:
 +
  $ mkdir git-test
 +
  $ echo "hello" > git-test/README
 +
 +
View status of changes
 +
  $ git status
 +
  # On branch my_branch
 +
  # Untracked files:
 +
  #  (use "git add <file>..." to include in what will be committed)
 +
  #
 +
  #      git-test/
 +
  nothing added to commit but untracked files present (use "git add" to track)
 +
 +
Add our new file to the local branch index:
 +
  $ git add git-test
 +
  $ git status
 +
  # On branch my_branch
 +
  # Changes to be committed:
 +
  #  (use "git reset HEAD <file>..." to unstage)
 +
  #
 +
  #      new file:  git-test/README
 +
  #
 +
 +
Commit changes
 +
  $ git commit -m "Example file for HOWTO"
 +
  Created commit ad9a1eb: Example file for HOWTO
 +
  1 files changed, 1 insertions(+), 0 deletions(-)
 +
  create mode 100644 git-test/README
 +
 +
Do some more work and commit local changes....
 +
 +
Now fetch the remote branch history:
 +
  $ git fetch
 +
 +
Merging remote branch changes:
 +
  $ git merge origin/master
 +
  ...
 +
 +
To present your patchset properly to other developers, please rebase your patches against the branch you are developing against:
 +
  $ git rebase origin/master
 +
Obviously replace "origin/master" by whatever branch you are developing against. If you have created a mess in your local patch queue, "git rebase -i" might help you out.
 +
 +
== Creating patches ==
 +
 +
Assuming your patches are the last three commits on your current local git branch, this is the easiest way to create patches from them:
 +
 +
  $ git format-patch -3
 +
 +
This will create three patch files in your current directory that you can then send to the samba-technical mailing list.
 +
 +
Note that if you have a number of patches against a specific branch and don't feel like counting them, the following works as well (e.g. against the master branch):
 +
 +
  $ git format-patch origin/master
 +
 +
This will create one patch file for every patch that is in your local branch but not in origin/master.
 +
 +
If you have more patches which belong together it's sometimes useful to export them into one file:
 +
 +
  $ git format-patch --stdout origin/master > master-featureX-01.patches.txt
 +
 +
== FAQ ==
 +
 +
'''Q.''' How do I revert a commit?
 +
 +
'''A.''' The "git reset" command allows you to reset the HEAD of the branch to any given point in history.  To go back one commit, run "git reset HEAD^".  This will keep your local changes and you can make any additional changes before re-commiting the new work.  Also see the "git commit --amend" command and the "git reset" man page for other examples.
 +
 +
 +
'''Q.''' How can I maintain a feature branch against the upstream Netatalk branches?
 +
 +
'''A.''' You clone the Netatalk repository as per the instructions above. Then you make a new feature branch:
 +
$ git checkout -b feature_foo master
 +
 +
Now you do your development in your feature branch. Any time the master branch gets too different to the code in your feature branch you should rebase your feature branch. The rebase rewinds your feature branch to the point there it was branched. Then it updates you feature branch to the HEAD of the master branch and re-applies your changes.
 +
 +
$ git rebase master
 +
First, rewinding head to replay your work on top of it...
 +
HEAD is now at 357f003... Add WERR_SERVICE_ALREADY_RUNNING.
 +
...
 +
Wrote tree 02299ef7c1cfa093248bfd9c6e3812805718845e
 +
Committed: e20a8c521d7860d9b7bd724ed5ea19c7306530ab
 +
 +
Rebase works best when you use it for local branches that are never pushed to a public repository, see [http://git.or.cz/gitwiki/GitFaq#head-c1dc263aca199d347f28872249e6c1f5d519a2df Why won't "git push" work after I rebased a branch?].

Revision as of 06:28, 31 August 2011

Contents

Overview

Netatalk source code is now hosted in a shared git repository to which only Netatalk Team members are allow to push to.

Git Installation

The examples in the following sections are based off of the tools and syntax used by git v1.5.3 or later. Either apt-get, yum, or make install the tools. See Git documentation for more details on this part.

Note that under Debian or Ubuntu, git is distributed in the git-core package. The git package contains the "GNU Interactive Tools".


Basic Netatalk Git

The master git repository is located at git://netatalk.git.sourceforge.net/gitroot/netatalk/netatalk. There is also a GitWeb installation.

Step Zero is to set your name and email address for commits:

  $ git config --global user.email Your.Email@domain.com
  $ git config --global user.name "Your Real Name"

Next, clone the repository:

  $ git clone git://netatalk.git.sourceforge.net/gitroot/netatalk/netatalk
...
  $ cd netatalk

List local and remote branches:

  $ git branch
    * master

  $ git branch -r
  origin/HEAD -> origin/master
  origin/branch-1-5-prep
  origin/branch-allea
  origin/branch-aurp
  origin/branch-compose-sp
  origin/branch-netatalk-1-6
  origin/branch-netatalk-2-0
  origin/branch-netatalk-2-1
  origin/branch-netatalk-2-2-0
  origin/branch-netatalk-CNID-refactored
  origin/branch-netatalk-afp-3x
  origin/branch-netatalk-afp-3x-dev
  origin/master
  origin/origin
  origin/vendor

Creating your own working branch from master:

 $ git checkout -b my_branch origin/master
 Branch my_branch set up to track remote branch refs/remotes/origin/master.
 Switched to a new branch "my_branch"

Do your own local work:

 $ mkdir git-test
 $ echo "hello" > git-test/README

View status of changes

 $ git status
 # On branch my_branch
 # Untracked files:
 #   (use "git add <file>..." to include in what will be committed)
 # 
 #       git-test/
 nothing added to commit but untracked files present (use "git add" to track)

Add our new file to the local branch index:

 $ git add git-test
 $ git status
 # On branch my_branch
 # Changes to be committed:
 #   (use "git reset HEAD <file>..." to unstage)
 #
 #       new file:   git-test/README
 #

Commit changes

 $ git commit -m "Example file for HOWTO"
 Created commit ad9a1eb: Example file for HOWTO
  1 files changed, 1 insertions(+), 0 deletions(-)
  create mode 100644 git-test/README

Do some more work and commit local changes....

Now fetch the remote branch history:

 $ git fetch 

Merging remote branch changes:

 $ git merge origin/master
 ...

To present your patchset properly to other developers, please rebase your patches against the branch you are developing against:

 $ git rebase origin/master

Obviously replace "origin/master" by whatever branch you are developing against. If you have created a mess in your local patch queue, "git rebase -i" might help you out.

Creating patches

Assuming your patches are the last three commits on your current local git branch, this is the easiest way to create patches from them:

 $ git format-patch -3

This will create three patch files in your current directory that you can then send to the samba-technical mailing list.

Note that if you have a number of patches against a specific branch and don't feel like counting them, the following works as well (e.g. against the master branch):

 $ git format-patch origin/master

This will create one patch file for every patch that is in your local branch but not in origin/master.

If you have more patches which belong together it's sometimes useful to export them into one file:

 $ git format-patch --stdout origin/master > master-featureX-01.patches.txt

FAQ

Q. How do I revert a commit?

A. The "git reset" command allows you to reset the HEAD of the branch to any given point in history. To go back one commit, run "git reset HEAD^". This will keep your local changes and you can make any additional changes before re-commiting the new work. Also see the "git commit --amend" command and the "git reset" man page for other examples.


Q. How can I maintain a feature branch against the upstream Netatalk branches?

A. You clone the Netatalk repository as per the instructions above. Then you make a new feature branch:

$ git checkout -b feature_foo master

Now you do your development in your feature branch. Any time the master branch gets too different to the code in your feature branch you should rebase your feature branch. The rebase rewinds your feature branch to the point there it was branched. Then it updates you feature branch to the HEAD of the master branch and re-applies your changes.

$ git rebase master
First, rewinding head to replay your work on top of it...
HEAD is now at 357f003... Add WERR_SERVICE_ALREADY_RUNNING.
...
Wrote tree 02299ef7c1cfa093248bfd9c6e3812805718845e
Committed: e20a8c521d7860d9b7bd724ed5ea19c7306530ab

Rebase works best when you use it for local branches that are never pushed to a public repository, see Why won't "git push" work after I rebased a branch?.

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox