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

2012年9月29日 星期六

git-diff between branches

git-diff on different branches.md

Before we diff, we have 4 branches :

tomteki-Mac-Pro:HearingLite tom$ git branch

TestUSB
* master
multiLanguage
testKbd

tomteki-Mac-Pro:HearingLite tom$

We want to diff the EditProfileViewController.m, to get the idea of where it is :

tomteki-Mac-Pro:HearingLite tom$ git diff --name-only master testKbd | grep EditProfileViewController

Classes/EditProfileViewController.h
Classes/EditProfileViewController.m
HearingLite/EditProfileViewController.h
HearingLite/EditProfileViewController.m

tomteki-Mac-Pro:HearingLite tom$

The above command will diff between two branches (testKbd and master).

Assume it is restructured from HearingLite/ path to Classes/ path (if doesn't , git ls-files can help ), the next thing to do is really diff them :

 git diff master:Classes/EditProfileViewController.m testKbd:HearingLite/EditProfileViewController.m

In this note, we use the 'git diff --name-only' to get the path of our target file. And use 'git diff [branch] : [file path]' to diff the file in various branches.

2011年1月23日 星期日

git 更改遠端資訊 的指令

為了轉移到新的伺服器,git 的 repository 要搬到新位置,所以 local 端的 repository 指標要換掉,下列指令依序就是轉換的步驟:

#> git remote -v
顯示目前指向哪些遠端的 repository? (URL 格式)

#> git remote rm origin
移除 URL 資訊

#> git remote add origin git@git-server:project_name
改變 URL 資訊,指向新位置 (若是用 gitosis ,就可以直接建立新的遠端 repository ,否則遠端的新增的 repository 必須先用 git init 或 git init --bare 處理過)
(目前為止,都還沒有對 remote repository 產生任何影響)

#> git push origin master
把 local repository 更新到 remote 端(這裡,才實際的更新了 remote repository)