1.安裝:yuminstallgit 2.Git常用命令 (1)gitinithere--創(chuàng)建本地倉(cāng)庫(kù)(repository),將會(huì)在文件夾">

日本三级片在线观看视频_西西大胆午夜人体视频无码_少妇无码一区二区_亚洲天堂超碰_极品少妇被猛的白浆直流_91精品云霸高清中文字幕_草草五月天伊人_久久少妇无码专区_欧美激欧美啪啪5老太_日韩在线在线成人

git命令使用

2016-01-14 18:12:40 18838

[摘抄自網(wǎng)絡(luò) ]

1.安裝:yum install git

2.Git 常用命令

    (1)git init here            -- 創(chuàng)建本地倉(cāng)庫(kù)(repository),將會(huì)在文件夾下創(chuàng)建一個(gè) .git 文件夾,.git 文件夾里存儲(chǔ)了所有的版本信息、標(biāo)記等內(nèi)容

    (2)git remote add origin git@github.com:winter1991/helloworld.git        -- 把本地倉(cāng)庫(kù)和遠(yuǎn)程倉(cāng)庫(kù)關(guān)聯(lián)起來(lái)。如果不執(zhí)行這個(gè)命令的話,每次 push 的時(shí)候都需要指定遠(yuǎn)程服務(wù)器的地址

    (3)git add                  -- 從本地倉(cāng)庫(kù)增刪,結(jié)果將會(huì)保存到本機(jī)的緩存里面

    (4)git rm

    (5)git commit -m "注釋"     -- 提交,把本機(jī)緩存中的內(nèi)容提交到本機(jī)的 HEAD 里面

    (6)git push origin master   -- 把本地的 commit(提交) push 到遠(yuǎn)程服務(wù)器上, origin 也就是之前 git remote add origin 那個(gè)命令里面的 origin,origin 替代了服務(wù)器倉(cāng)庫(kù)地址:git push git@github.com:winter1991/helloworld.git master

    (7)git pull origin master   -- 從遠(yuǎn)程服務(wù)器 pull 新的改動(dòng)

    (8)git status               -- 查看狀態(tài)

    (9)git add -A               -- 提交全部修改

3. git 配置:

    git config --global user.name "xxx"      -- 配置用戶名,上傳本地 repository 到服務(wù)器上的時(shí)候,在 Github 上會(huì)顯示這里配置的上傳者信息

    git config --global user.email "xxx"     -- 配置郵箱

    git config --list        查看配置列表

    配置 sshkey : 上傳代碼時(shí)使用這個(gè) sshkey 來(lái)確認(rèn)是否有上傳權(quán)限

    (1)創(chuàng)建本地 ssh : ssh-keygen -t rsa -C "Github 的注冊(cè)郵箱"

    (2) 在 Github 中添加這個(gè) sshkey : 

        復(fù)制  C:Documents and SettingsAdministrator.sshid_rsa.pub 文件中的內(nèi)容;

        登錄 Github --> Account Setting  --> SSH-KEY --> Add SSH-KEY --> 粘貼id_rsa.pub中的內(nèi)容;

    (3) 驗(yàn)證: ssh -T git@github.com

        出現(xiàn) Hi xxx! Youve successfully authenticated, but GitHub does not provide shell access. 說(shuō)明配置成功,可以連接上 Github

4.建立倉(cāng)庫(kù) repository 

    git init here       -- 創(chuàng)建本地倉(cāng)庫(kù)

    git remote add origin git@github.com:用戶名/倉(cāng)庫(kù)名.git    -- 把本地倉(cāng)庫(kù)和遠(yuǎn)程倉(cāng)庫(kù)關(guān)聯(lián)起來(lái), 如果不執(zhí)行這個(gè)命令的話,每次 push 的時(shí)候都需要指定遠(yuǎn)程服務(wù)器的地址                  

5.從遠(yuǎn)程倉(cāng)庫(kù)中下載新的改動(dòng):

    git pull origin master

6提交本地修改到遠(yuǎn)程倉(cāng)庫(kù)中:

    git add

    git add -A      -- 將改動(dòng)添加到本地倉(cāng)庫(kù)中

    git rm xxx      -- 從本地倉(cāng)庫(kù)中刪除指定文件

    git rm -r xxx   -- 從本地倉(cāng)庫(kù)中刪除指定文件夾

    git commit -m "注釋"    -- 把本機(jī)緩存中的內(nèi)容提交到本機(jī)的 HEAD 里面

    git push origin master      -- 把本地的 commit push 到遠(yuǎn)程倉(cāng)庫(kù)中

6.使用 .gitignore 文件忽略指定的內(nèi)容:

    (1) 在本地倉(cāng)庫(kù)根目錄創(chuàng)建 .gitignore 文件。Win7 下不能直接創(chuàng)建,可以創(chuàng)建 ".gitignore." 文件,后面的標(biāo)點(diǎn)自動(dòng)被忽略;

    (2) 過(guò)濾文件和文件夾: [Tt]emp/ 過(guò)濾 Temp emp 文件夾; *.suo 過(guò)濾 .suo 文件;

    (3) 不過(guò)濾文件和文件夾: !*.c

提交成功!非常感謝您的反饋,我們會(huì)繼續(xù)努力做到更好!

這條文檔是否有幫助解決問(wèn)題?

非常抱歉未能幫助到您。為了給您提供更好的服務(wù),我們很需要您進(jìn)一步的反饋信息:

在文檔使用中是否遇到以下問(wèn)題: