git 本地操作
git 簡介 1
、git是分布式的scm,svn是集中式的
2、git每個歷史版本儲存完整的檔案,svn儲存檔案差異
3、git可離線完成大部分操作,svn則相反
4、git有著更優雅的分支和合併實現
5、git有更強的撤銷修改和修改版本歷史的能力
6、git速度更快,效率更高
1.切換最新版本,自己喜歡的版本
輸入 : which -a git
2.顯示我們用的是哪個版本的git
git -- version
vim .bash_profile
輸入:export path=/usr/local/git/bin:$path
載入一下source .bash_profiel
再次看一下剛剛修改是否成功:
hairongchen:~$git —version
顯示:git version 2.2.1
二、配置git 輸入命令自動完成
1.進入
2.在終端進入剛解壓的位置
再進入 contrib/completion/ 資料夾
發現有四個檔案,而下面這兩個檔案是我們需要的
git-completion.bash
git-prompt.sh
把上面這兩個檔案拷貝到當前使用者home目錄下
cp git-completion.bash ~/
cp git-prompt.sh ~/
修改.bash_profile
vim .bash_profile
輸入以下內容
# copy contrib/copmletion/git-completion.bash to your home directory and source it
# linux users should add the line below to your .bashrc
. ~/git-completion.bash
#copy contrib/completion/git-prompt.sh to your home directory and source it
#linux users should add the line below to your .bashrc
. ~/git-prompt.sh
export git_ps1_showdirtystate=1
# export ps1='\w$(__git_ps1 " (%s)")\$'
export
ps1='\u:\w$(__git_ps1 " (%s)")\$ '
上面這兩個檔案主要是在git 輸入命令時可以自動完成及有內容提示
,防止輸入命令出錯
儲存退出並source 一下.bash_profile
3.此時我們輸入 git confi 並按 tab鍵,就會自動補齊
輸入 git config - - 就會列出了一些引數
三、git 簡單配置
1>.git最基本的配置
通以上安裝及配置git 輸入命令自動完成,還需最後一步就可以使用了
git config —global user.name***
***設定成你自己的使用者名稱
git config —global user.email ***
***輸入自己的email
2>git配置的三個級別
git config —system
git config —global
git config —local
local 對當前倉庫的,從優先來說,local最高,其次是global ,因為他針對是當前的使用者,最後是system
查git config 文件
三種方式
git config —help
git help config
man git-config
3>git配置的增刪改查
1.上面的增加使用者名稱,email一種, 乙個鍵後跟乙個值
2.用git config —global —add user.name rhc
add 表明他有多個這樣的鍵值對
可以根據這個鍵查詢這個值 git config user.name
也可以用git config —get user.name來查詢
通過以上兩個命令查詢,得出使用者名稱是add 進去的rhc
3.用git config —list —global 可以檢視所的有鍵值,發現user.name有兩個
只是使用的是最後乙個rhc
hairongchen:git-master$ git config --list --global
user.name=chenhairong
user.name=rhc
4.刪除
hairongchen:git-master$ git config --global --unset user.name
出現警告:
warning: user.name has multiple values
我們需要user.name後面加乙個表示式如:git config --global --unset user.name rhc
再查:hairongchen:git-master$ git config --list --global
user.name=chenhairong
發現user.name 只有乙個值,只有乙個值時刪除就不用加表示式了如:
git config --global --unset user.name
再查:git config --get user.name,就查不到了
我們再增加回去:
git config --global user.name rhc
5.修改:
git config --global user.email [email protected],把以前的email 改了:
hairongchen:git-master$ git config --list --global
user.name=rhc
4>為git子命令配置別名
給checkout 取別名co:git config --global alias.co checkout
branch,status,commit配置別名如下:
git config --global alias.br branch
git config --global alias.st status
git config --global alias.ci commit
輸入 git c 再按tab鍵出現,多了co,ci 兩個命令,我們以後可用ci來commit,co來checkout
hairongchen:git-master$ git c
c cherry citool cm commit
ca cherry-pick clean co config
checkout ci clone column
git 後面接引數
輸入命令發現:git log 發現後面輸出了很多內容
使用下面命令:git config --global alias.lol "log —oneline"
再用git lol發現一行一行,很整齊
mac下的git的安裝與簡單的配置
git 本地操作 git 簡單介紹 1 git是分布式的scm,svn是集中式的 2 git每乙個歷史版本號儲存完整的檔案,svn儲存檔案差異 3 git可離線完畢大部分操作,svn則相反 4 git有著更優雅的分支和合併實現 5 git有更強的撤銷改動和改動版本號歷史的能力 6 git速度更快,效...
Mac上Git的安裝與簡單使用
mac上git的安裝與簡單使用 一 安裝 二 使用 1 1 建立乙個新的repository ios test 可參考 2 在mac中新建乙個本地倉庫 local repository並通過終端切換到該目錄 cd users qianhua desktop wen local repository ...
Mac下Github的安裝與使用
mac下安裝和使用git 一 安裝 使用homebrew安裝 brew install git 二 建立ssh key,配置git 1 設定使用者名稱和郵箱 git config global user.name chuming03403 git config global user.email c...