顯示具有 git 標籤的文章。 顯示所有文章
顯示具有 git 標籤的文章。 顯示所有文章

2015/07/17

How to use git to do development #2

Recall

Last time I have shown you my configurations. This time I am going to share my visions about git merge and git rebase.

What is merge and what is rebase?

If you are confused about these 2 operations, I suggest you to go through slides here.
For merge, it adds a node (commit) in order to join two parallel branches (with a parent node some where).
For rebase, it moves one of the parallel branches onto another one. “NO” new nodes will be added during this operation.

Workflow?

By workflows, I mean how you tactic and regulate branches in your project. For example, master is a production branch while hotfix are branches that branched off from master. Those hotfix branches must be merged or rebased eventually etc.
The concept of workflow is a kind of regulations or agreements between developers.
IMHO, you do not need this if you are one man band :) Do whatever you like.
If you are not sure which one to start, I suggest you to go through this one first. Even you do not agree with the writer, he gives you hints for modeling your workflow with git.

So, which workflow I have adopted?

Actually, I am a fans of terminal. I would like to keep all my history as linear as possible which is easier for me to read. Therefore, I will embrace git rebase instead of git merge.
However, this does not means I do not git merge at all. Since result of git merge and git rebase are the same eventually, I will use git merge if I am running out of time.
Alternatively, if you are good at using GUI tools like SourceTree, go for git merge instead of git rebase since those GUI is able to tell you commits coming from which branch.
​

2015/04/26

How to use git to do development #1

Recall

As mention in previous blog, I will show you my git configuration in this blog.

Notes for reading

  • Comments inside the file
Beside showing reasons why we need to write such config, I strongly recommend you to setup configuration marked with MUST. Otherwise, you may messy up your repository’s history.

For example, if you omit user configuration, personal information will not be attached to commits you created.
  • Feel free to extend the configuration
To be honest, my configuration sourced from here. You can further edit my configurations as what I do on the source.

What’s next

Views about two major workflows (merge vs rebase)
​

2015/03/13

How to use git to do development #0

Preface

As git becomes popular, more and more developers are trying to make use of it in order to manage their project’s revisions.

However, they may not know where to start and how to do better.

For sharing and showing benefits of using git on development, I am going to write several blogs for documenting how and why some approaches are better to follow.

Hopes you will enjoy this series.

Feel free to point out mistakes I have made :).

Learning resources

Newbie

An online tutorial which go through typical usages of git.

Advanced

An open source book explains git, including introduction, workflows and demonstrations. I strongly recommend you to go through this book if you would like to master Git.

If above links cannot help you, checkout this one which provided by github.

What’s next

To be honest, this blog just suggest you links so that you know where to start and get help.
In next blog, I will show you my git configurations and explain why I wrote like that.
​

2013/10/30

Setup a git server via http protocol

Background
1. apached2 installed
2. Ubuntu 12.04 LTS
3. git installed
4. You are root

Steps
Enable git on http (git push should be work after that)
Follow the 2nd reference link, to summarize
1. Import dav module (I have no idea what dav is at this point)
2. Modify directory configuration so that others can access your git directory on your web server
3. Actually I use following config on git.conf since I don't need authentication
    <Location /my-new-repo.git>
       DAV on
    </Location>
4. Restart your apache

Create git repository on your web server (git clone should be work after that)
Follow the 1st reference link.
(EDIT
/* create from existing project */
$ cd /var/www/htdocs/ $ git clone --bare /path/to/git_project gitproject.git
$ chown -R www-data:www-data ./gitproject.git $ cd gitproject.git $ mv hooks/post-update.sample hooks/post-update $ chmod a+x hooks/post-update
$ git update-server-info
/* create from scratch */
$ cd /var/www/htdocs/ $ git init --bare gitproject.git
$ chown -R www-data:www-data ./gitproject.git $ cd gitproject.git $ mv hooks/post-update.sample hooks/post-update $ chmod a+x hooks/post-update
$ git update-server-info
)

Testing
git clone http://<hostname>/<dir>.git
$(some work)
git push

Linking up ticket system Bugzilla with git
https://github.com/gera/gitzilla seems to be a solution. However I cannot make them work. Leave me a message if you know how :'(

Enjoy :D

Reference
1. http://git-scm.com/book/en/Git-on-the-Server-The-Protocols
2. http://www.kernel.org/pub/software/scm/git/docs/howto/setup-git-server-over-http.txt