Changes

Jump to navigation Jump to search
4,183 bytes added ,  18:06, 2 December 2014
Use proper name, except in code or URIs
Line 1: Line 1:  
<noinclude>{{TeamHeader|Activity Team}}</noinclude>
 
<noinclude>{{TeamHeader|Activity Team}}</noinclude>
 
: '''[[Talk:Activity Team/Git FAQ | Post new questions here]]'''.
 
: '''[[Talk:Activity Team/Git FAQ | Post new questions here]]'''.
=== Help! I suddenly can't connect to Gitorious! ===
+
==Using GitHub (github.com)==
:The [http://osuosl.org/ OSUOSL], which hosts Gitorious, has an aggressive IP blacklist policy.  If you once were able to push but now cannot, send an email to support@osuosl.org requesting that your IP be removed from the blacklist.
+
=== Help! I suddenly can't connect to GitHub! ===
 +
:Please contact to [https://github.com/contact GitHub support], or look at [https://help.github.com/ GitHub FAQ]
   −
To check if the problem is with your key, try:
+
=== How do I create an account on github.com? ===
   −
ssh -v gitorious@git.sugarlabs.org
+
:[http://github.com/join Join] using the link on the upper right menu on the Home Page.
   −
A successful ssh setup results in a normal response "Need SSH_ORIGINAL_COMMAND" then connection is closed.
+
===How do I migrate a project to GitHub? ===
   −
=== How do I create an account on git.sugarlabs.org? ===
+
:Please follow the [[Activity Team/How_to_migrate_from_Gitorious|instructions here]] to first set up your project's entry in GitHub.
 
  −
:[http://git.sugarlabs.org/users/new Register] using the link on the upper right menu on the Home Page.
  −
 
  −
===How do I migrate a project to git.sugarlabs.org? ===
  −
 
  −
:Please follow the [[Activity Team/How_to_migrate_from_OLPC|instructions here]] to first set up your project's entry in Gitorious.
      
=== How do I create a new project? ===
 
=== How do I create a new project? ===
   −
:First set up the project in gitorious as per above.
+
:First set up the project in GitHub as per above.
    
:Go to your project directory and type:
 
:Go to your project directory and type:
  git init
+
  <nowiki>git init
   −
git add .
+
git add .
git commit -a
+
git commit -a
git remote add origin gitorious@git.sugarlabs.org:[your project name]/mainline.git
+
git remote add origin git@github.com:username/[your project name].git
git push origin master
+
git push origin master</nowiki>
    
:Hence forth, just use:
 
:Hence forth, just use:
Line 37: Line 32:  
  git commit -a -m "I am the commit message"
 
  git commit -a -m "I am the commit message"
 
:to avoid opening an editor.
 
:to avoid opening an editor.
 +
 +
=== How do I add an additional committer to my project? ===
 +
 +
:Go to: <nowiki>https://github.com/USERNAME/PROJECTNAME/settings/collaboration</nowiki> . Type a username in the box and click "add collaborator"
    
=== How do I create a fork of an existing project? ===
 
=== How do I create a fork of an existing project? ===
   −
:Click on the Repositories Tab of the project page in Gitorious. Click on "Mainline". A link will appear on the right-hand side of the page saying, "Clone repository".
+
:Go to project page, and click the "Fork" button in the top
    
:Note: if you (as maintainer) are making a clone to replace a corrupted mainline on your local machine, you'll need to:
 
:Note: if you (as maintainer) are making a clone to replace a corrupted mainline on your local machine, you'll need to:
   −
   git clone  git://git.sugarlabs.org/yourproject/mainline.git
+
   git clone  git://github.com/username/yourproject.git
    
:and update [remote] section
 
:and update [remote] section
   −
  git config remote.origin.url gitorious@git.sugarlabs.org:yourproject/mainline.git
+
  git config remote.origin.url git@github.com:username/project.git
    
----
 
----
Line 54: Line 53:  
:in the .git/config file, you may have to change:
 
:in the .git/config file, you may have to change:
 
  [remote "origin"]
 
  [remote "origin"]
     url = git://git.sugarlabs.org/yourproject/yourbranch.git
+
     url = git://github.com/username/yourproject.git
    
:to:
 
:to:
 
  [remote "origin"]
 
  [remote "origin"]
     url = gitorious@git.sugarlabs.org:yourproject/yourbranch.git
+
     url = git@github.com:username/yourproject.git
 +
 
    
=== How do I request a merge? ===
 
=== How do I request a merge? ===
   −
:Click on the Repositories Tab of the project page in Gitorious. Click on "Mainline". A link will appear on the right-hand side of the page saying, "Request merge".
+
:Go to your GitHub fork page and follow the steps of the images
   −
=== How do I add a committer? ===
+
[[File:Merge-Step1.png]] <br />
 +
Click on the Pull Request button
 +
[[File:Merge-Step2.png]]<br />
 +
You will get something like that
 +
[[File:Merge-Step3.png]]<br />
 +
If you used another branch for changes, just change it in the image
 +
[[File:Merge-Step4.png]]<br />
 +
Click on Create Pull request
 +
[[File:Merge-Step5.png]]<br />
 +
Edit the title/description of the pull request, and click on Create pull request. Now the commiter will review it]]
   −
:Click on the Repositories Tab of the project page in Gitorious. Click on "Mainline". A link will appear on the right-hand side of the page saying, "Add Committer".
+
===What is the difference between a branch and a repository?===
 +
 
 +
When you make a clone of a project on GitHub, it creates a "repository". You can see the list of repositories associated with a project by clicking on the Repository Tab. Branches are clones within a repository (created with git branch and accessed through git checkout). Git merge commands refer to branches, not repositories, so in order to merge a repository back into mainline, you need to pull (fetch followed by merge) it as if it were a patch.
 +
 
 +
git merge [your repository name]  # This won't work
 +
 
 +
git pull [git://git.sugarlabs.org/[your project name]/[your repository name].git master  # This will work
 +
 
 +
===How do I select which branch I am working on?===
 +
 
 +
git checkout master
 +
 
 +
git checkout sucrose-0.84
 +
 
 +
===How do I merge changes from master into a branch?===
 +
 
 +
git checkout sucrose-0.84
 +
git rebase master
 +
 
 +
===How do I push my branch to GitHub?===
 +
 
 +
Use <code>git push origin <your branch name></code>, e.g.,
 +
 
 +
git push origin sucrose-0.84
 +
 
 +
See [[Development_Team/Release#Branching]] for more details as to when and why you branch.
 +
 
 +
==Patches==
 +
 
 +
=== How do I generate a patch? ===
 +
 
 +
git diff > blah.patch
 +
:or
 +
diff -rup [old] [new]
 +
:or
 +
git format-patch HEAD^
 +
 
 +
It is preferable that you generate your patch from the root directory of your project.
 +
 
 +
=== How do I apply a patch? ===
 +
 
 +
First, take a look at what changes are in the patch. You can do this easily with '''git apply''' f.e:
 +
 
 +
git apply --stat sugar_fixes.patch
 +
 
 +
Note that this command does not apply the patch, but only shows you the stats about what it’ll do. After opening the patch file with your favorite editor, you can see what the actual changes are.
 +
 
 +
Next, you’re interested in how troublesome the patch is going to be. Git allows you to test the patch before you actually apply it.
 +
 
 +
git apply --check sugar_fixes.patch
 +
 
 +
If you don’t get any errors, the patch can be applied cleanly. Otherwise you may see what trouble you’ll run into. To apply the patch, we can  use '''git am''' instead of '''git apply'''. The reason for this is that git am allows you to sign off an applied patch. This may be useful for later reference.
 +
 
 +
git am --signoff
 +
 
 +
Taken from: [http://ariejan.net/2009/10/26/how-to-create-and-apply-a-patch-with-git/]
 +
 
 +
==== Appying a patch from thunderbird ====
 +
*Right click save as
 +
* cat <save-as>  | git am --signoff
 +
 
 +
=== How do I send a patch to a maintainer? ===
 +
 
 +
First, you may need to install git-mail:
 +
 
 +
sudo yum -y install git-email
 +
 
 +
 
 +
An easy way to send a complete patch is to commit in git, then do:
 +
 
 +
git format-patch -s -1
 +
git send-email --to <maintainer> --cc <mailing-list> <filename>
 +
 
 +
For example, you can do:
 +
 
 +
git send-email --to <maintainer> --subject=mail-subject  0003-service-name-deprecated.patch
 +
 
 +
git send-email --to <maintainer> --cc <mailing-list> --subject=new-patch --cover-letter --annotate 0001-*.patch
 +
 
 +
git send-email --to <maintainer> --cc <mailing-list> --subject=new-patch --cover-letter --annotate --no-validate 0001-*.patch
 +
 
 +
 
 +
You can also generate a [[#How do I request a merge?|merge request]] on GitHub from your forked repository to mainline.
 +
 
 +
=== How do I send a patch to the Sugar developers? ===
 +
 
 +
git send-email --to=sugar-devel@lists.sugarlabs.org 0001*.patch
 +
 
 +
==== How do I set up git-send-email? ====
 +
 
 +
1. Install git-email
 +
 
 +
2. Configure your ~/.gitconfig file
 +
[user]
 +
    email = foo@sugarlabs.org
 +
    name = Foo Bar
 +
 
 +
[sendemail]
 +
    smtpserver = smtp.gmail.com
 +
    smtpserverport = 465
 +
    smtpuser = foo@sugarlabs.org
 +
    smtpencryption = ssl
 +
    suppresscc = author
 +
 
 +
3. In the directory where patch is present use:
 +
 
 +
git send-email HEAD^..HEAD --to "sugar-devel@lists.sugarlabs.org" patchname.patch
 +
 
 +
You can configure the destination address so you don't need to specify
 +
it manually every time:
 +
 
 +
git config sendemail.to "sugar-devel <sugar-devel@lists.sugarlabs.org>"
 +
 
 +
You need to do this for each of the repositories you are working on (e.g. sugar + sugar-toolkit).
 +
 
 +
For more git send-email options please see ''man git send-email''
 +
 
 +
=== How do I amend a commit message? ===
 +
 
 +
If you have "dirty" history (i.e., other patches that are not in mainline
 +
yet) please create a branch carrying only those two patches and push
 +
that branch:
 +
 
 +
git checkout -b to-push origin/master
 +
git cherry-pick <commit ID of first patch>
 +
git commit --amend
 +
(fix summary)
 +
git cherry-pick <commit ID of second patch>
 +
git commit --amend
 +
(fix summary)
 +
git push origin to-push:master
 +
 
 +
You can remove the branch afterwards:
 +
 
 +
git checkout master
 +
git branch -d to-push
 +
 
 +
=== How do I revert a commit? ===
 +
 
 +
Again, best to do this on a branch as per [[#How do I amend a commit message?|above]]
 +
 
 +
Find the commit id and then:
 +
 
 +
git revert <commit ID>
 +
 
 +
=== As a maintainer, how do I merge a patch? ===
 +
 
 +
:git-pull does a combination of fetch and merge, so to merge a patch...
 +
 
 +
git pull git://github.com/username/myproject-clone.git master
 +
 
 +
=== What is the community protocol for submitting patches? ===
 +
 
 +
# Introduce yourself to the community.
 +
# Don't leave questions without a reply.
 +
# Whenever you take a task that someone else was doing, mention it explicitly so others aren't concerned about wasting efforts.
 +
# Ask when you don't understand.
 +
# Answer other people's questions when you can.
 +
 
 +
==Internationalization work flow==
 +
 
 +
{{Note/note|This section is for Gitorious only|The following does not apply to GitHub.}}
 +
 
 +
The i18n work flow involves an interplay between the Pootle server, where translations are maintained and Gitorious, where the master POT files are updated. '''Note''': As a maintainer, you may update the .pot file associated with your project, but never update .po files. These are updated for you in the i18n work flow.
    
=== How do I get translations for my project? ===
 
=== How do I get translations for my project? ===
Line 74: Line 246:  
# Fill a ticket requesting that your POT file be added to Pootle. Assign the ticket to "Localization".
 
# Fill a ticket requesting that your POT file be added to Pootle. Assign the ticket to "Localization".
 
# Add User Pootle to the list of committers on your project.
 
# Add User Pootle to the list of committers on your project.
  −
=== What if my project has a binary blob? ===
  −
  −
:You may have to use the --force flag.
  −
  −
git push -fv
      
=== How do I stay in sync with translations being pushed from the Pootle server? ===
 
=== How do I stay in sync with translations being pushed from the Pootle server? ===
Line 99: Line 265:  
  git push
 
  git push
   −
=== How do I update the Tag field in Gitorious? ===
+
==Misc.==
   −
git tag -m "Release 36" v36 HEAD
+
=== What if my project has a binary blob? ===
git push --tags
     −
=== As a maintainer, how do I merge a patch? ===
+
:You may have to use the --force flag.
   −
:git-pull does a combination of fetch and merge, so to merge a patch...
+
git push -fv
   −
git pull git://git.sugarlabs.org/myproject/myproject-clone.git master
+
=== How do I update the Tag field in GitHub? ===
   −
=== How do I send a patch to a maintainer? ===
+
  git tag -m "Release 36" v36 HEAD
 
+
  git push --tags
An easy way to send a complete patch is to commit in git, then do:
  −
 
  −
git format-patch -s -1
  −
  git send-email --to <maintainer> --cc <mailing-list> <filename>
  −
 
  −
===How do I select which branch I am working on?===
  −
 
  −
git checkout master
  −
 
  −
  git checkout sucrose-0.84
  −
 
  −
===How do I merge changes from master into a branch?===
  −
 
  −
git checkout sucrose-0.84
  −
git rebase master
     −
=== How do I generate a patch? ===
+
=== How do I list tags ? ===
git diff > blah.patch
  −
:or
  −
diff -rup [old] [new]
  −
:or
  −
git format-patch HEAD^
     −
It is preferable that you generate your patch from the root directory of your project.
+
git tag -l
   −
===How do I send a patch to the developers?===
+
=== How do I checkout specific tags? ===
   −
  git send-email --to=sugar-devel@lists.sugarlabs.org 0001*.patch
+
  git checkout <tag_name>
   −
You may need to install git-mail:
+
=== How do I delete specific tags? ===
   −
  sudo yum -y install git-email
+
  git tag -d <tag_name>
 +
git push origin :refs/tags/<tag_name>
   −
===Commit access behind firewall===
+
===How can I get commit access behind firewall?===
    
:If you are behind a firewall and need only ''Read-Only'' access to git.sugarlabs.org, you can use HTTP links, like
 
:If you are behind a firewall and need only ''Read-Only'' access to git.sugarlabs.org, you can use HTTP links, like
  http://git.sugarlabs.org/git/<project>/mainline.git
+
  https://github.com/username/<project>.git
 
   
:But if you need commit access, you'll have to set up an SSH proxy tunnel. One option is using [http://www.torproject.org/ Tor]. So, install all requirements:
 
:But if you need commit access, you'll have to set up an SSH proxy tunnel. One option is using [http://www.torproject.org/ Tor]. So, install all requirements:
 
* [http://www.torproject.org/ Tor] to make tunnel via Tor network,
 
* [http://www.torproject.org/ Tor] to make tunnel via Tor network,
Line 156: Line 301:     
:Setup your tunnel in SSH. Add the following lines to your ~/.ssh/config
 
:Setup your tunnel in SSH. Add the following lines to your ~/.ssh/config
  Host git.sugarlabs.org
+
  Host github.com
     User gitorious
+
     User git
     ProxyCommand /usr/bin/connect -S 127.0.0.1:9050 git.sugarlabs.org 22
+
     ProxyCommand /usr/bin/connect -S 127.0.0.1:9050 github.com 22
    
:Then start [http://www.torproject.org/ Tor], you can just run it on behalf of your account
 
:Then start [http://www.torproject.org/ Tor], you can just run it on behalf of your account
Line 167: Line 312:  
:''NOTE:'' If you use [http://www.torproject.org/ Tor] on a regular basis, please consider the possibility of [http://www.torproject.org/docs/tor-doc-relay.html.en helping] Tor by donating your bandwidth.
 
:''NOTE:'' If you use [http://www.torproject.org/ Tor] on a regular basis, please consider the possibility of [http://www.torproject.org/docs/tor-doc-relay.html.en helping] Tor by donating your bandwidth.
   −
===Commits are not visible on git.sugarlabs.org event pages===
+
===Why are my commits not visible on git.sugarlabs.org event pages?===
    
Check that your email address on git.sugarlabs.org account page is the same like in [[Activity_Team/Git_Tutorial#Initialize_git_global_settings|global git settings]] or in local repository setting (if you set user.email once):
 
Check that your email address on git.sugarlabs.org account page is the same like in [[Activity_Team/Git_Tutorial#Initialize_git_global_settings|global git settings]] or in local repository setting (if you set user.email once):
 
  git config user.email
 
  git config user.email
  −
===Branch vs Repository===
  −
  −
When you make a clone of a project on gitorious, it creates a "repository". You can see the list of repositories associated with a project by clicking on the Repository Tab. Branches are clones within a repository (created with git branch and accessed through git checkout). Git merge commands refer to branches, not repositories, so in order to merge a repository back into mainline, you need to pull (fetch followed by merge) it as if it were a patch.
  −
  −
git merge [your repository name]  # This won't work
  −
  −
git pull [git://git.sugarlabs.org/[your project name]/[your repository name].git master  # This will work
      
=== New activity maintainer walkthrough ===
 
=== New activity maintainer walkthrough ===
Line 184: Line 321:  
Here's an IRC session recording the very first steps of new activity maintainer learning how to merge patches:
 
Here's an IRC session recording the very first steps of new activity maintainer learning how to merge patches:
   −
:[[Activity_Team/Git_Activity_Maintainer_Walkthrough]]
+
*:[[Activity_Team/Git_Activity_Maintainer_Walkthrough]]
       
[[Category:Activity Team]]
 
[[Category:Activity Team]]
 
[[Category:FAQ]]
 
[[Category:FAQ]]

Navigation menu