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

2011年6月30日 星期四

git checkout 某一個版本

一般用git checkout -b
可以建立分支
並且由目前此分支最新的code所branch出去

但是
如果有以下需求該怎麼辦

主幹版本已經有16, 17, 18
目前最新是18
如何得到16所出來的分支呢

git log
可以得到commit number
使用下列command

git branch branchname commitnumber

透過Facebook分享

2011年4月20日 星期三

charles git 教學

robotrepo.sh

do?
init
sync
clone kernel
clone uboot
...

git fetch //從origin的地方下載source到local端
會以origin開頭為準

git merge origin/xxx
//會merge到origin的xxx目錄

repo不管kernel_imx and bootable

.repo/manifest.xml這個檔案會決定repo要管理哪些檔案

修改檔案完要做的動作
system/extras/mcustub/
修改完
git commit (under mywork)
git checkout rtk
git fetch
git merge mywork
git push


新增檔案
git checkout mywork
git add filename
git commit .....
git checkout rtk
git merge mywork
git push

repo forall
讓你一次操作所有repo管得到的git folder

repo forall -c git fetch korg
一次更新server資料到local cache

korg是為什麼要命名此名字呢
可以使用下列指令看
git remote -v


git branch -r
可以看到local cache的資料 (from server)


repo forall -c git checkout rtk
將local cache更新到rtk

--
如何加入一個新的目錄

要注意幾件事情
1.
新加的目錄
要checkout成原來的branch name
ex. imx_r9.4

2.
使用git --mirror 加新加入的folder加入repo內

3.
更新manifest.xml

透過Facebook分享

2011年3月23日 星期三

Fix: git add file fail

承繼

git add file fail


以及

git add file fail - part2


現在連git svn也會受到影響



現在把.git的權限都打開

sudo chmod 777 -R .git

目前可以正常加入檔案

透過Facebook分享

git add file fail - part2

繼

git add file fail


這一篇


我另外將這個png檔案放到另外一個folder - gittest
使用git add卻ok


看來應該是git的bug

該怎麼回報呢

透過Facebook分享

2011年3月22日 星期二

git add file fail

git add res/drawable-hdpi/r_btn_vol.png
error: insufficient permission for adding an object to repository database .git/objects

error: res/drawable-hdpi/r_btn_vol.png: failed to insert into database
error: unable to index file res/drawable-hdpi/r_btn_vol.png
fatal: adding files failed


透過Facebook分享

2011年3月21日 星期一

使用git svn 抓取 subversion上的source code (卻無法得到subversion上的log)

git svn init http://subversion.royaltek.com/svn/PND/CV-7000/trunk/Src/AP/AuxIn
git svn fetch

但是沒有log紀錄

怎麼辦呢?

使用git svn fetch revisionfrom:revisionto

也沒有辦法

透過Facebook分享

2011年3月11日 星期五

同時使用git與subversion開發project

接續此篇 -

同時使用subversion與git開發project


B人員使用git開發


A人員使用subversion開發

B人員修改1.txt 並commit to git repository


sync to subversion


A人員使用subversion log功能就可以看出差異



透過Facebook分享

同時使用subversion與git開發project

A人員使用subversion開發
B人員使用git開發

接續此篇

A人員修改1.txt並上傳subversion

此時B人員如何將差異的部份整進local端呢

先確認local端資料

使用git log

git svn log

發現內容上並無差異
代表local的subversion repository比subversion server端來的舊
  • 更新subversion repository
  • Check log

有新的資料
  • Get latest data from subversion
  • 確認資料via git log


Reference:

透過Facebook分享

將原本git維護的專案上傳到subversion server

你需要使用git-svn

 sudo apt-get install git-svn

正在用git開發維護某個project


此時
需要使用subversionr進行維護
先使用git svn init
指定subversion 目錄位置


建立subversion server目錄



接下來將維護的檔案上傳subversion server

  • git repository update from subversion
git svn fetch
Server端目錄不存在會有下列error

  • Subversion update from git repository
  • Check上傳資料


完成


Reference:



透過Facebook分享

2011年3月10日 星期四

[git] 只commit某些檔案進git repository

使用git做source control
使用git commit會發現一次把所有修改過的檔案都加到git repository中

如果只是想要加入某些真的有意義的檔案該怎麼辦呢

使用git add -p來挑選要commit的檔案

他會一次show一個有修改過的檔案
並show出修改內容差異
再問你要不要Stage this hunk
選擇y就是要


nelsonchung@robot:~/temp/gitsubversiontest$ git status
# On branch master
# Changed but not updated:
#   (use "git add ..." to update what will be committed)
#   (use "git checkout -- ..." to discard changes in working directory)
#
#       modified:   1.txt
#       modified:   2.txt
#
no changes added to commit (use "git add" and/or "git commit -a")
nelsonchung@robot:~/temp/gitsubversiontest$ git add -p
diff --git a/1.txt b/1.txt
index bb4b503..8103efd 100644
--- a/1.txt
+++ b/1.txt
@@ -1,2 +1,3 @@
 1.text
 2.txt
+3.txt
Stage this hunk [y,n,q,a,d,/,e,?]? y

最後再做git commit就可以嚕

透過Facebook分享

2011年1月25日 星期二

觀看某一次commit的修改變化

可以使用git log -p看全部的改變

也可以另外使用git show "commitid"



nelsonchung@ubuntu:~/tmp/TestGitRevert$ git show 27dc6863e1e4c836ae9022f0ec0dd7a5fb17b1d9
commit 27dc6863e1e4c836ae9022f0ec0dd7a5fb17b1d9
Author: Nelson Chung
Date:   Tue Jan 25 18:31:52 2011 +0800

    add 12

diff --git a/record b/record
index 3bb459b..08fe19c 100644
--- a/record
+++ b/record
@@ -9,3 +9,4 @@
 9
 10
 11
+12


Refrence:
http://git-scm.com/documentation


透過Facebook分享

git revert fail

nelsonchung@ubuntu:~/tmp$ mkdir TestGitRevert
nelsonchung@ubuntu:~/tmp$ cd TestGitRevert
nelsonchung@ubuntu:~/tmp/TestGitRevert$ git init
Initialized empty Git repository in /home/nelsonchung/tmp/TestGitRevert/.git/
nelsonchung@ubuntu:~/tmp/TestGitRevert$ vim record
nelsonchung@ubuntu:~/tmp/TestGitRevert$ git add record
nelsonchung@ubuntu:~/tmp/TestGitRevert$ git commit -am "add 1"
[master (root-commit) b8c3b3f] add 1
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 record
nelsonchung@ubuntu:~/tmp/TestGitRevert$ echo "2" >> record
nelsonchung@ubuntu:~/tmp/TestGitRevert$ git commit -am "add 2"
[master 0e77f52] add 2
 1 files changed, 1 insertions(+), 0 deletions(-)
nelsonchung@ubuntu:~/tmp/TestGitRevert$ echo "3" >> record
nelsonchung@ubuntu:~/tmp/TestGitRevert$ git commit -am "add 3"
[master acdf9d0] add 3
 1 files changed, 1 insertions(+), 0 deletions(-)
nelsonchung@ubuntu:~/tmp/TestGitRevert$ echo "4" >> record
nelsonchung@ubuntu:~/tmp/TestGitRevert$ git commit -am "add 4"
[master 6814dd7] add 4
 1 files changed, 1 insertions(+), 0 deletions(-)
nelsonchung@ubuntu:~/tmp/TestGitRevert$ echo "5" >> record
nelsonchung@ubuntu:~/tmp/TestGitRevert$ git commit -am "add 5"
[master 38e2ca3] add 5
 1 files changed, 1 insertions(+), 0 deletions(-)
nelsonchung@ubuntu:~/tmp/TestGitRevert$ echo "6" >> record
nelsonchung@ubuntu:~/tmp/TestGitRevert$ git commit -am "add 6"
[master f825601] add 6
 1 files changed, 1 insertions(+), 0 deletions(-)
nelsonchung@ubuntu:~/tmp/TestGitRevert$ echo "7" >> record
nelsonchung@ubuntu:~/tmp/TestGitRevert$ git commit -am "add 7"
[master 3a4c807] add 7
 1 files changed, 1 insertions(+), 0 deletions(-)
nelsonchung@ubuntu:~/tmp/TestGitRevert$ echo "8" >> record
nelsonchung@ubuntu:~/tmp/TestGitRevert$ git commit -am "add 8"
[master 090a8e4] add 8
 1 files changed, 1 insertions(+), 0 deletions(-)
nelsonchung@ubuntu:~/tmp/TestGitRevert$ echo "9" >> record
nelsonchung@ubuntu:~/tmp/TestGitRevert$ git commit -am "add 9"
[master 5d0cb60] add 9
 1 files changed, 1 insertions(+), 0 deletions(-)
nelsonchung@ubuntu:~/tmp/TestGitRevert$ echo "10" >> record
nelsonchung@ubuntu:~/tmp/TestGitRevert$ git commit -am "add 10"
[master 99a9780] add 10
 1 files changed, 1 insertions(+), 0 deletions(-)
nelsonchung@ubuntu:~/tmp/TestGitRevert$ git log
commit 99a9780e7762aae78fefa3c4ed8d0c49e8f485ed
Author: Nelson Chung
Date:   Tue Jan 25 18:19:48 2011 +0800

    add 10

commit 5d0cb60c2ec6f606b029fe48174dbd61c9a2a1ee
Author: Nelson Chung
Date:   Tue Jan 25 18:19:40 2011 +0800

    add 9

commit 090a8e475674b9415eae7649a00c49dbc5500ab9
Author: Nelson Chung
Date:   Tue Jan 25 18:19:34 2011 +0800

    add 8

commit 3a4c807c3becedd4a26e4d280970abe5be854aa9
Author: Nelson Chung
Date:   Tue Jan 25 18:19:29 2011 +0800

    add 7

commit f825601df9e50d69251be8229979e697c8353410
Author: Nelson Chung
Date:   Tue Jan 25 18:19:23 2011 +0800

    add 6

commit 38e2ca349369feb3cf923c007d12f72712ed281d
Author: Nelson Chung
Date:   Tue Jan 25 18:19:19 2011 +0800

    add 5

commit 6814dd7c28103eff870527fa413f804edc6d1e24
Author: Nelson Chung
Date:   Tue Jan 25 18:19:14 2011 +0800

    add 4

commit acdf9d0647f454d712b18447e59858facbe11905


nelsonchung@ubuntu:~/tmp/TestGitRevert$ git revert 5d0cb60c2ec6f606b029fe48174dbd61c9a2a1ee
Automatic revert failed.  After resolving the conflicts,
mark the corrected paths with 'git add ' or 'git rm '
and commit the result.


I modify the file - record manually.

nelsonchung@ubuntu:~/tmp/TestGitRevert$ vim record
nelsonchung@ubuntu:~/tmp/TestGitRevert$ echo "11" >> record
nelsonchung@ubuntu:~/tmp/TestGitRevert$ git commit -am "add 11"
[master 546fdd5] add 11
 1 files changed, 1 insertions(+), 0 deletions(-)
nelsonchung@ubuntu:~/tmp/TestGitRevert$ git revert HEAD
Finished one revert.
[master 994882e] using git revert HEAD Revert "add 11"
 1 files changed, 0 insertions(+), 1 deletions(-)
nelsonchung@ubuntu:~/tmp/TestGitRevert$ git log
commit 994882e46dc89e792d8cef8d7f76e78f8dba16ef
Author: Nelson Chung
Date:   Tue Jan 25 18:30:21 2011 +0800

    using git revert HEAD
    Revert "add 11"
    
    This reverts commit 546fdd5c61048efffaacde291d5a90b5a8cd7d1d.

commit 546fdd5c61048efffaacde291d5a90b5a8cd7d1d
Author: Nelson Chung
Date:   Tue Jan 25 18:29:44 2011 +0800

    add 11

commit 99a9780e7762aae78fefa3c4ed8d0c49e8f485ed
Author: Nelson Chung
Date:   Tue Jan 25 18:19:48 2011 +0800

    add 10

commit 5d0cb60c2ec6f606b029fe48174dbd61c9a2a1ee
Author: Nelson Chung
Date:   Tue Jan 25 18:19:40 2011 +0800

    add 9

commit 090a8e475674b9415eae7649a00c49dbc5500ab9
Author: Nelson Chung
Date:   Tue Jan 25 18:19:34 2011 +0800

    add 8

commit 3a4c807c3becedd4a26e4d280970abe5be854aa9
Author: Nelson Chung
Date:   Tue Jan 25 18:19:29 2011 +0800

    add 7

commit f825601df9e50d69251be8229979e697c8353410
Author: Nelson Chung
Date:   Tue Jan 25 18:19:23 2011 +0800

nelsonchung@ubuntu:~/tmp/TestGitRevert$ cat record 
1
2
3
4
5
6
7
8
9
10


nelsonchung@ubuntu:~/tmp/TestGitRevert$ echo "11" >> record
nelsonchung@ubuntu:~/tmp/TestGitRevert$ cat record 
1
2
3
4
5
6
7
8
9
10
11
nelsonchung@ubuntu:~/tmp/TestGitRevert$ git commit -am "add 11"
[master 27dd00a] add 11
 1 files changed, 1 insertions(+), 0 deletions(-)
nelsonchung@ubuntu:~/tmp/TestGitRevert$ echo "12" >> record
nelsonchung@ubuntu:~/tmp/TestGitRevert$ git commit -am "add 12"
[master 27dc686] add 12
 1 files changed, 1 insertions(+), 0 deletions(-)
nelsonchung@ubuntu:~/tmp/TestGitRevert$ cat record
1
2
3
4
5
6
7
8
9
10
11
12
nelsonchung@ubuntu:~/tmp/TestGitRevert$ git log
commit 27dc6863e1e4c836ae9022f0ec0dd7a5fb17b1d9
Author: Nelson Chung
Date:   Tue Jan 25 18:31:52 2011 +0800

    add 12

commit 27dd00ad510b22ceab445ca9f56aa5357219483a
Author: Nelson Chung
Date:   Tue Jan 25 18:31:46 2011 +0800

    add 11

commit 994882e46dc89e792d8cef8d7f76e78f8dba16ef
Author: Nelson Chung
Date:   Tue Jan 25 18:30:21 2011 +0800

    using git revert HEAD
    Revert "add 11"
    
    This reverts commit 546fdd5c61048efffaacde291d5a90b5a8cd7d1d.

commit 546fdd5c61048efffaacde291d5a90b5a8cd7d1d
Author: Nelson Chung
Date:   Tue Jan 25 18:29:44 2011 +0800

    add 11

commit 99a9780e7762aae78fefa3c4ed8d0c49e8f485ed
Author: Nelson Chung
Date:   Tue Jan 25 18:19:48 2011 +0800

    add 10

commit 5d0cb60c2ec6f606b029fe48174dbd61c9a2a1ee
Author: Nelson Chung
Date:   Tue Jan 25 18:19:40 2011 +0800

    add 9

commit 090a8e475674b9415eae7649a00c49dbc5500ab9
Author: Nelson Chung
Date:   Tue Jan 25 18:19:34 2011 +0800

nelsonchung@ubuntu:~/tmp/TestGitRevert$ git revert 27dc6863e1e4c836ae9022f0ec0dd7a5fb17b1d9
Finished one revert.
[master c363ee7] Revert "add 12"
 1 files changed, 0 insertions(+), 1 deletions(-)
nelsonchung@ubuntu:~/tmp/TestGitRevert$ 27dc6863e1e4c836ae9022f0ec0dd7a5fb17b1d9
27dc6863e1e4c836ae9022f0ec0dd7a5fb17b1d9: command not found
nelsonchung@ubuntu:~/tmp/TestGitRevert$ git revert 27dc6863e1e4c836ae9022f0ec0dd7a5fb17b1d9
Finished one revert.
# On branch master
nothing to commit (working directory clean)
nelsonchung@ubuntu:~/tmp/TestGitRevert$ git status
# On branch master
nothing to commit (working directory clean)
nelsonchung@ubuntu:~/tmp/TestGitRevert$ git log
commit c363ee7dbc35bd3783e730ac9cd3f22ca9c24fbe
Author: Nelson Chung
Date:   Tue Jan 25 18:32:33 2011 +0800

    Revert "add 12"
    
    This reverts commit 27dc6863e1e4c836ae9022f0ec0dd7a5fb17b1d9.

commit 27dc6863e1e4c836ae9022f0ec0dd7a5fb17b1d9
Author: Nelson Chung
Date:   Tue Jan 25 18:31:52 2011 +0800

    add 12

commit 27dd00ad510b22ceab445ca9f56aa5357219483a
Author: Nelson Chung
Date:   Tue Jan 25 18:31:46 2011 +0800

    add 11

commit 994882e46dc89e792d8cef8d7f76e78f8dba16ef
Author: Nelson Chung
Date:   Tue Jan 25 18:30:21 2011 +0800

    using git revert HEAD
    Revert "add 11"
    
    This reverts commit 546fdd5c61048efffaacde291d5a90b5a8cd7d1d.

commit 546fdd5c61048efffaacde291d5a90b5a8cd7d1d
Author: Nelson Chung
Date:   Tue Jan 25 18:29:44 2011 +0800

    add 11

commit 99a9780e7762aae78fefa3c4ed8d0c49e8f485ed
Author: Nelson Chung
Date:   Tue Jan 25 18:19:48 2011 +0800

    add 10

commit 5d0cb60c2ec6f606b029fe48174dbd61c9a2a1ee
Author: Nelson Chung
nelsonchung@ubuntu:~/tmp/TestGitRevert$ git revert 27dd00ad510b22ceab445ca9f56aa5357219483a
Finished one revert.
[master 2ea4b6f] Using git revert 27dd00ad510b22ceab445ca9f56aa5357219483a
 1 files changed, 0 insertions(+), 1 deletions(-)
nelsonchung@ubuntu:~/tmp/TestGitRevert$ git log
commit 2ea4b6f665ed5415dacc6bd43185263b5a0b8ee9
Author: Nelson Chung
Date:   Tue Jan 25 18:33:25 2011 +0800

    Using git revert 27dd00ad510b22ceab445ca9f56aa5357219483a
    
    Revert "add 11"
    
    This reverts commit 27dd00ad510b22ceab445ca9f56aa5357219483a.

commit c363ee7dbc35bd3783e730ac9cd3f22ca9c24fbe
Author: Nelson Chung
Date:   Tue Jan 25 18:32:33 2011 +0800

    Revert "add 12"
    
    This reverts commit 27dc6863e1e4c836ae9022f0ec0dd7a5fb17b1d9.

commit 27dc6863e1e4c836ae9022f0ec0dd7a5fb17b1d9
Author: Nelson Chung
Date:   Tue Jan 25 18:31:52 2011 +0800

    add 12

commit 27dd00ad510b22ceab445ca9f56aa5357219483a
Author: Nelson Chung
Date:   Tue Jan 25 18:31:46 2011 +0800

    add 11

commit 994882e46dc89e792d8cef8d7f76e78f8dba16ef
Author: Nelson Chung
Date:   Tue Jan 25 18:30:21 2011 +0800

    using git revert HEAD
    Revert "add 11"
    
    This reverts commit 546fdd5c61048efffaacde291d5a90b5a8cd7d1d.

commit 546fdd5c61048efffaacde291d5a90b5a8cd7d1d
Author: Nelson Chung
Date:   Tue Jan 25 18:29:44 2011 +0800

It is ok for me to use "git revert" now.
Is that a bug or the author of git - Linus Torvalds think there is no need to do git revert when there is too less "git commit"?

透過Facebook分享

2011年1月24日 星期一

git 移除已加入的檔案

使用git rm 會連帶把你的檔案一起刪除

你可以使用git add -i
選項3
然後會列出你加入的檔案
這時候按下檔案的編號 ex 1, 2, 3 ...
就會出現*代表已選中要移除的檔案
確定後
按下enter按鍵離開

透過Facebook分享

使用git add 一次增加很多新增的檔案

一般用git control source code
可以使用git add filename
一次一個將source code加到git index中

如果你一次增加許多files
你可以使用git add .
來一次把所有的檔案加入到index

or
git add -i  (使用互動方式增加檔案)


*** Commands ***
  1: status  2: update  3: revert  4: add untracked
  5: patch  6: diff  7: quit  8: help

1顯示目前狀態
3移除檔案



Reference:
http://wildjcrt.pixnet.net/blog/post/26510201

透過Facebook分享

2011年1月3日 星期一

git merge --no-ff VerifyA2Panel_from_VerifyBluetooth

nelsonchung@gps1004:~/myandroid9.1/kernel_imx$ git merge --no-ff VerifyA2Panel_from_VerifyBluetooth
Auto-merging arch/arm/mach-mx5/mx51_babbage.c
Merge made by recursive.
Auto packing the repository for optimum performance. You may also
run "git gc" manually. See "git help gc" for more information.
Counting objects: 10580, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (10363/10363), done.
Writing objects: 100% (10580/10580), done.
Total 10580 (delta 7774), reused 0 (delta 0)
 arch/arm/mach-mx5/mx51_babbage.c    |   58 +++++++++-------
 drivers/input/keyboard/Makefile     |    2 +
 drivers/input/keyboard/rtk_vkeyb.c  |  129 +++++++++++++++++++++++++++++++++++
 drivers/mxc/ipu3/Makefile           |    2 +
 drivers/mxc/ipu3/ipu_device.c       |    2 +
 drivers/mxc/ipu3/ipu_disp.c         |    8 +-
 drivers/mxc/pmic/mc13892/pmic_adc.c |   96 +++++++++++++-------------
 drivers/video/mxc/Makefile          |    2 +
 drivers/video/mxc/ldb.c             |   12 ++--
 drivers/video/mxc/mxc_epdc_fb.c     |    1 +
 drivers/video/mxc/mxc_ipuv3_fb.c    |    6 +-
 drivers/video/mxc/mxcfb_epson.c     |    2 +
 12 files changed, 236 insertions(+), 84 deletions(-)
 create mode 100644 drivers/input/keyboard/rtk_vkeyb.c


透過Facebook分享

2010年12月30日 星期四

Gnu make: $< and $@的用法

Follow 

4.12.1 Syntax of Static Pattern Rules

我們可以簡化makefile的內容

一個makefile的內容如下

objects = main.o Eye.o Nose.o Ear.o Mouse.o Face.o

all: $(objects)
gcc $(objects) -o main

$(objects): %.o: %.c
gcc -c $< -o $@

clean:
rm main.o Eye.o Nose.o Ear.o Mouse.o Face.o main

藍色部份第一行中, %稱為stem
gnu make會替我們match出符合的.o檔的file name
然後交給gcc去作compile
$<: 能夠找出prerequisites的name
$@: 則能夠找出target的name

make之後你可以得到以下結果
gcc -c main.c -o main.o
gcc -c Eye.c -o Eye.o
gcc -c Nose.c -o Nose.o
gcc -c Ear.c -o Ear.o
gcc -c Mouse.c -o Mouse.o
gcc -c Face.c -o Face.o
gcc main.o Eye.o Nose.o Ear.o Mouse.o Face.o -o main


是使用git作source control
你也可以使用git log -p來查看差異


透過Facebook分享

2010年12月29日 星期三

刪除由git建出的branch

請使用git branch -D branchname

ex.
git branch
列出有三個分支A, B, C
假設你位於A要刪除C
git branch -D C

如果你位於A又要刪掉A呢
git branch -D A
這時候會出現error message
error: Cannot delete the branch 'C' which you are currently on.
所以你需要先切換到B
git checkout B
在刪除A
git branch -D A

透過Facebook分享

整合branch A上的改變到branch B by using git merge

man git-merge手冊上說明

有兩個branch:master and topic

想要把topic上3次的commit - A, B, C都commit到master上?該怎麼辦呢

原本狀況

                        A---B---C topic
                       /
               D---E---F---G master

想要的結果
                        A---B---C topic
                        /               \
               D---E---F---G---H master

1. 將所在的branch切換到master
git checkout master

2. 進行merge
git merge topic

就ok嚕


透過Facebook分享