1. 程式人生 > >使用Git工具

使用Git工具

主要記錄本人學習git工具過程

一、Hello world

進入github官網,點選read the guide,即學習入門hello world。
主要是學習如何在網頁上操作,如何建立倉庫,建立分支,對比分支,然後合併分支。

二、工具使用

2.1 安裝git工具

本人使用的是Anaconda,因此直接在Prompt中,輸入

conda install git

2.2 測試

隨便clone一個專案到本地

cd MyProject
git clone http://github.com......

2.2 簡便使用

首先在網頁版新建一個倉庫,然後git clone到本地。
新增檔案流程:
需要將檔案或資料夾複製到對應的clone目錄,然後

git add filename #加入暫存區
git commit -m "comment" #提交修改
git push origin # 將本當前分支推送至origin主機對應的分支

2.3 新建分支

git branch newname#新建新分支
git checkout newname#轉到新分支
git add files
git commit -m "comment"
git push origin newname:newname(git push origin newname)

2.4 全域性設定

可以全域性設定使用者名稱和郵箱,作為提交者的資訊

git config -- global
user.name "username" git config -- global user.email "email_adress"

每次提交遠端程式碼的時候,都需要輸入github賬號密碼,可以永久記住賬號密碼

git config --global credential.helper store

學習資料

簡便版
複雜版
常用命令