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

2016年1月30日 星期六

[Ubuntu, Git] 在 Ubuntu 14.04 上安裝 Git server

前言:

        最近因為某些需求,必須在安裝 Git 伺服器。由於對 Ubuntu 較為熟悉,因此選擇在此 distribution 上安裝。

安裝前的準備:

        1. 一台已安裝好的 Ubuntu 伺服器(我選擇 Ubuntu 14.04 LTS)
        2. 在安裝 Ubuntu 的過程中選擇 ssh 或透過 apt-get 安裝

步驟:

        1. 安裝 Git
            $ sudo apt-get install git git-core

        2. 確認 Git 版本(Ubuntu 14.04 內建 1.9.1)
            $ git --version

        3. 在 server side 建立新專案
            $ cd Path/to/your/git
            $ sudo mkdir new_project.git
            $ cd new_project.git
            $ sudo git --bare init

        4. 如果要用 ssh 存取 Git server,則每一個要存取的人都必須要是這台 linux 的帳號。為了方便,我們將建立一個群組,將所有要存取 Git 的人加入。
            $ sudo groupadd git
            $ sudo user mod -a -G git [YOUR ACCOUNT]
            $ sudo chgrp -R git Path/to/your/git
            $ sudo chmod -R 777 Path/to/your/git

        5. 在 client side,我們可以 clone 一個 repository 下來
            $ git clone ssh://YOUR ACCOUNT@GIT SERVER IP:Path/to/your/git/new_project.git

            最後輸入密碼,就確定 Git server 安裝大功告成!

2014年3月10日 星期一

[Ubuntu, Git, GitHub] 在 Ubuntu 12.04 上使用 GitHub

最近看了些新聞以及求才訊息,發現不少公司都將 GitHub 視為工程師加分的一個條件。

在公司內,專案開發使用的版本控制系統為 Subversion。

趁著撰寫軟體驗證 (Proof Of Concept) 的時候,將自己的程式碼上傳至並學習 GitHub。

筆者大多數的程式碼皆在 Ubuntu 上進行開發,故下列文章內容將以 Ubuntu 12.04 作為範例。

首先,GitHub 仍然是以 Git 為基礎的,所以必須在 Ubuntu 12.04 上安裝 Git

sudo apt-get install git

接下來,必須對 Git 進行配置 (configure)

git config --global user.name "Your GitHub Username"
git config --global user.email "Your GitHub 註冊 Email"

如果,今天你已經有現存的 repository,請先複製 (clone) 下來

git clone https://github.com/Your GitHub Username/Your Repository Name.git

接著,可在您複製的資料夾內進行專案管理。

如果您新增了一份檔案,最終您必須將檔案新增至 repository。

git add Your New File

新增完畢,將檔案 commit 至 repository

git commit -m 'Your commit message'

最後,將您修改的檔案 push 回 GitHub

git remote add origin https://github.com/Your GitHub Username/Your Repository Name.git

git push origin master ( 輸入您的帳號與密碼 )

完成上述流程,一切就大功告成囉!