2012年6月8日 星期五

[git server][ubuntu] Build up git server (using Ubuntu linux)

1. Install git:
sudo apt-get install git-core


2. 在server端建立放置所有projects的目錄:
cd /home/happy/
sudo mkdir git


3. 在server端建立project:
步驟3,5,6是每開一個新project就要做一遍的,假設現在我開了一個專案叫new_project
cd /home/happy/git
sudo mkdir new_project.git (new_project which is Project Name)

# 如果是第二次新增project,記得也要改該資料夾的群組跟權限,相關步驟在step 4有寫
cd new_project.git
(Initialized empty Git repository in /home/freeman/git/multilanguage_title_bar.git/)
sudo git –bare init
chmod 777 ../new_project.git -R
在local端,假設我的project資料夾是/path/to/your/projects/new_project


1. 初始化git:
cd /path/to/your/projects/new_project
git init


2. 把我們遠端的repository加到git remote:
git remote add origin ssh://Remote_login_account@Remote_login_host/var/git/new_project.git/
If want change ssh, Please type
git remote set-url origin ssh://root@111.2.1.103/home/freeman/CVS/UBEE_D3_CableRG.git


3. 把我們local的程式碼丟上去:(每次commit的例行步驟)
git add .
git commit -m ‘註解’
git push origin master
local,假設我的project資料夾是/path/to/your/projects/new_project


1. git clone (checkout) local:
mkdir /home/happy/git.temp
cd /home/happy/git.tempgit clone ssh://git@111.200.100.111/home/happy_remote/git/test.git
Then will checkout project from server use SSH.


1. git commit && git pull:
mkdir /home/happy/git.temp
cd /home/happy/git.temptouch new_file.txt
git add .
git push origin master
cd ..
mkdir /home/happy/git.temp2 -p
cd /home/happy/git.temp2
git pull

First, clone a remote git repository and cd into it:
$ git clone git://example.com/myproject
$ cd myproject

Next, look at the local branches in your repository:
$ git branch
* master

But there are other branches hiding in your repository! You can see these using the -a flag:
$ git branch -a
* master
origin/HEAD
origin/master
origin/v1.0-stable
origin/experimental

If you just want to take a quick peek at an upstream branch, you can check it out directly:
$ git checkout origin/experimental

But if you want to work on that branch, you’ll need to create a local tracking branch:
$ git checkout -b experimental origin/experimental

Now, if you look at your local branches, this is what you’ll see:
$ git branch

master
* experimental


If you lazy to type passwod, can ref SSH免密碼登入


Reference:

0 意見:

張貼留言