...
Code Block |
---|
git clone git://github.com/dhubler/sipxecs.git |
Example:
Code Block |
---|
[mirceac@decebal ~user@localhost~]$ mkdir work [mirceac@decebal ~user@localhost~]$ cd work [mirceac@decebal workuser@localhost]$ git clone git://github.com/dhubler/sipxecs.git Initialized empty Git repository in /home/mirceac/work/sipxecs/.git/remote: Counting objects: 127119, done.remote: Compressing objects: 100% (29946/29946), done.remote: Total 127119 (delta 84094), reused 126491 (delta 83609)Receiving objects: 100% (127119/127119), 751.56 MiB | 1.69 MiB/s, done. Resolving deltas: 100% (84094/84094), done.Checking out files: 100% (11021/11021), done. [mirceac@decebal workuser@localhost]$ ls sipxecs |
Now, verify to what branch you are positioned using the following command:
...
Watch the following code-snipped to accomplish this
Example:
Code Block |
---|
[mirceac@decebal sipxecsuser@localhostsipxecs]$ git branch * master [mirceac@decebal sipxecsuser@localhostsipxecs]$ git branch -a * master remotes/origin/HEAD -> origin/master remotes/origin/master remotes/origin/master-4.2 remotes/origin/release-4.2 [mirceac@decebal sipxecsuser@localhostsipxecs]$ git checkout -b master-4.2 origin/master-4.2 Branch master-4.2 set up to track remote branch master-4.2 from origin. Switched to a new branch 'master-4.2' [mirceac@decebal sipxecsuser@localhostsipxecs]$ git status # On branch master-4.2 nothing to commit (working directory clean) [mirceac@decebal sipxecsuser@localhostsipxecs]$ git branch master * master-4.2 [mirceac@decebal sipxecsuser@localhostsipxecs]$ |
Make your changes
Before starting working, you have to make sure that you are in sync with the latest source code. Assuming that you have to base your work on master-4.2 branch follow the steps from below:
...
As a rule, after the title a blank line should be inserted and then the patch description
Example:
Code Block |
---|
[mirceac@decebal sipxecsuser@localhostsipxecs]$ git checkout master-4.2 Switched to branch 'master-4.2' [mirceac@decebal sipxecsuser@localhostsipxecs]$ git status # On branch master-4.2nothing to commit (working directory clean) [mirceac@decebal sipxecsuser@localhostsipxecs]$ git rebase origin/master-4.2 Current branch master-4.2 is up to date. [mirceac@decebal sipxecsuser@localhostsipxecs]$ git status # On branch master-4.2 nothing to commit (working directory clean) [mirceac@decebal sipxecsuser@localhostsipxecs]$ git checkout -b TEST Switched to a new branch 'TEST' [mirceac@decebal sipxecsuser@localhostsipxecs]$ git status # On branch TEST nothing to commit (working directory clean) [mirceac@decebal sipxecsuser@localhostsipxecs]$ ****after all your changes are done**** [mirceac@decebal sipxecsuser@localhostsipxecs]$ git status # On branch TEST # Changed but not updated: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: sipXconfig/neoconf/etc/freeswitch/freeswitch.xml # no changes added to commit (use "git add" and/or "git commit -a") [mirceac@decebal sipxecsuser@localhostsipxecs]$ git commit -a [TEST 747365d] UC-TEST: Patch title 1 files changed, 1 insertions(+), 1 deletions(-) [mirceac@decebal sipxecsuser@localhostsipxecs]$ git status # On branch TEST nothing to commit (working directory clean) |
...
Code Block |
---|
Falling back to patching base and 3-way merge... Auto-merging sipXconfig/neoconf/src/org/sipfoundry/sipxconfig/bulk/csv/Index.java CONFLICT (content): Merge conflict in sipXconfig/neoconf/src/org/sipfoundry/sipxconfig/bulk/csv/Index.java Auto-merging sipXconfig/neoconf/src/org/sipfoundry/sipxconfig/common/AbstractUser.java Auto-merging sipXconfig/neoconf/test/org/sipfoundry/sipxconfig/bulk/ldap/UserMapperTest.java CONFLICT (add/add): Merge conflict in sipXconfig/neoconf/test/org/sipfoundry/sipxconfig/bulk/ldap/UserMapperTest.java Auto-merging sipXconfig/web/src/org/sipfoundry/sipxconfig/site/admin/ldap/LdapServer.java Failed to merge in the changes.Patch failed at 0001 XX-6279: Import contact information from LDAP When you have resolved this problem run "git rebase --continue".If you would prefer to skip this patch, instead run "git rebase --skip". To restore the original branch and stop rebasing run "git rebase --abort". [mirceac@decebal sipxecsuser@localhostsipxecs]$ git add sipXconfig/neoconf/src/org/sipfoundry/sipxconfig/bulk/csv/Index.java [mirceac@decebal sipxecsuser@localhostsipxecs]$ git add sipXconfig/neoconf/test/org/sipfoundry/sipxconfig/bulk/ldap/UserMapperTest.java [mirceac@decebal sipxecsuser@localhostsipxecs]$ git rebase --continue |
Code Block |
---|
git format-patch master-4.2 -o <output directory> |
Code Block |
---|
[mirceac@decebal sipxecsuser@localhostsipxecs]$ git format-patch master-4.2 -o /home/mirceac/patches/ /home/mirceac/patches/0001-UC-TEST-Patch-title.patch [mirceac@decebal sipxecsuser@localhostsipxecs]$ |
Code Block |
---|
git checkout sipXconfig/neoconf/etc/freeswitch/freeswitch.xml |
...
http://help.github.com/forking/
http://stackoverflow.com/questions/67699/how-do-i-clone-all-remote-branches-with-git
http://www.question-defense.com/2009/02/04/add-a-ssh-key-to-your-github-account-for-a-linux-server
http://www.kernel.org/pub/software/scm/git/docs/git-merge.html
More tips
- If you know subversion pretty well check this out: http://git.or.cz/course/svn.html
- There are a few tech talks with helpful information about git:
- Video
- Audio
- Book
- Reference
There is several git GUIs - if you use Gnome giggle is a good choice
Panel |
---|
yum install giggle |
If you encounter problems when rebasing or merging 'git mergetool' command can be used to launch graphical 3-way merging tool. Make sure that you run it from the root of your git repository.
Panel |
---|
git rebase master-4.2
|
'checkout' and 'status' are probably 2 most commonly used commands. To add svn-like aliases for them:
Panel |
---|
git config --global alias.co checkout |
And now you can use those aliases, 'st' and 'co' instead of the fully spelled out keywords:
Panel |
---|
git st # instead of git status |
Enable colorized output for various commands:
Panel |
---|
git config --global color.branch auto |
If you use bash, use git-completion.bash. It enables simply pressing: <TAB> to display a list of potential commands, arguments and parameters. For example:
Code Block |
---|
git checkout <TAB> |
will show the list of branches.
Source it in your ~/.bashrc:
Panel |
---|
. /path-to/git-completion.bash |
To have the current branch appear on your bash prompt:
Panel |
---|
export PS1='[xecsdev:\u@\h`__git_ps1` \W]\$ ' |
If you want to roll back to a particular point in history ( say some feature that is currently broken, but formerly worked a week ago and is blocking your progress ): Look at your git repository using giggle. You will see each commit has a global UUID. You can pick out the specific point in history when the world still looked rosy by doing:
Panel |
---|
git checkout -b proxy-still-worked UUID |