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

2014年5月1日 星期四

Git and git-p4

Perforce is great source version tool for owner of company, because it's centralize control and can track each client behavior. But I don't like it anymore.
So I used Git to manage my local repo that is sync from perforce server. Use git to track my local commits and use p4/p4v to submit changes to Perforce server. But the work flow will complex and waste time(file always locks to read only with p4).

Few couple months passed, I found the tool git-p4 that can manage p4 repo like remote git branch. That similar like git-svn tool (git 與 git-svn 簡單教學)

The git-p4 is wrote by python and it integrates to git source tree. you need turn off the compile flag(ON_PYTHON) when you compiling git. In official build on git website, the NO_PYTHON is enable, so you can't use it with git-p4.

$ git p4
fatal: git was built without support for git-p4 (NO_PYTHON=1).

Please clone the git and switch to tag v1.9.2
$ git clone https://github.com/git/git
$ git checkout v1.9.2 -b v1.9.2

Follow INSTALL document to compile and install git, Please make sure the python already install in your environment (NO_PYTHON will turn OFF when you compile)
$ make prefix=/usr all 
$ sudo make prefix=/usr install

Check your git and git-p4 are ready to use

$ git --version
git version 1.9.2

$ git-p4
usage: /usr/bin/git-p4  [options]

valid commands: clone, rollback, debug, commit, rebase, branches, sync, submit

Try /usr/bin/git-p4  --help for command specific help.

Add p4 alias to your ~/.gitconfig

[alias]
    p4 = !/usr/bin/git-p4

Don't forget your p4 command and environemnt

$ export P4CLIENT=[your_client_name]
$ export P4HOST=[perforce_server_ip]:1666
$ export P4USER=[login_user_name]
$ export P4EDITOR=vim


Now, you can clone a proj from perforce.

# Clone a repository and covert all change list to git log
$ git p4 clone //depot/path/project@all myproject

# Clone a repository without log
$ git p4 clone //depot/path/project myproject
  
# Do some work and commit to your local git repo
$ git add foo.py
$ git commit foo.py
# Submit your local commit to remote repo (Perforce server)
# git p4 will create a change list for commit
$ git p4 submit

# Synchronize with Perforce (almost like 'git fetch' and 'get pull')
$ git p4 rebase
All done, enjoy it! :)

2010年6月3日 星期四

用 vim 有效閱讀 Android framework 程式碼

Android 發展至今,程式碼的部份不斷的膨脹,越來越大。要整個通透需要花點時間,而這篇文章主要是談論如何利用 vim 來快速閱讀 Android 程式碼,這邊的程式碼包含底層 C , C++ and Java framework 的部份,當然如果你是寫 Application 的人,也許用 Eclipse 會快一點,不過如果你想了解 Android framework 的實作也可以透過下面的方式去瀏覽。

請自我確認一下,如果你有下面幾個症狀,請務必看完這篇文章,應該對你很有幫助。
  1. 如果你還在用 grep 找 key word
  2. 如果你還在開多個 tab 然後下指令,去開某個含有特定 key word 的源碼
  3. 如果你很勤勞的想每個檔案都打開看完,並了解所有 class or object 特性
如果你沒有這樣的症狀,那您可以省下寶貴時間不用看下面的文章。

2010年5月31日 星期一

git 與 git-svn 簡單教學

git 是個很棒的版本控制工具,不需要建置 Server 就可以達到版本控制的目的,其他的好處就不多說。
雖然它是發展出來控制程式碼的版本,但是對於一般文件的也是可以達到版本控制的目的,另外一種說法就是可以幫你備份。簡單來說,如果你正在寫論文,請好好學習一下 git 的用法,它對你備份論文與實驗是很有幫助的。

下面說明如何透過 git-svn 與 svn server 溝通並取得 source code

安裝 git-core git-svn
# sudo apt-get install git-core  git-svn
取得 svn source code
# git svn clone http://url/svn/trunk/ test
完全可以離線作業的 log
# git log
想 用 svn format來看,沒問題
# git svn log
# git svn log -v
想知道source code從那邊下來的
# git svn  info