本篇文章為大家展示了如何理解git的本地操作庫(kù)以及遠(yuǎn)程操作庫(kù),內(nèi)容簡(jiǎn)明扼要并且容易理解,絕對(duì)能使你眼前一亮,通過(guò)這篇文章的詳細(xì)介紹希望你能有所收獲。

Git 是一個(gè)開(kāi)源的分布式版本控制系統(tǒng),用于敏捷高效地處理任何或小或大的項(xiàng)目。目前很多企業(yè)
1、windows下git建立本地倉(cāng)庫(kù)
$ git config --global user.name "hehe"
$ git config --global user.email "[email protected]"
2、創(chuàng)建密匙
$ ssh-keygen -t rsa -b 4096 -C "hehe@163com"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/hehe/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/heheiscool/.ssh/id_rsa.
Your public key has been saved in /c/Users/heheiscool/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:gx8BsPtCRTwoKsD0D+tQeo+XIgl31mzKp6Qw2UrAIlQ heheiscool@163com
The key's randomart image is:
+---[RSA 4096]----+
|o. E.+o |
|..+ .oo. |
|.o =. ... |
|= o += . . |
|*+.o=.= S |
|=+==o+.. o |
|++.+=+o . |
|.+.oo+ |
|. . . |
+----[SHA256]-----+
3、查詢創(chuàng)建的ssh秘匙
$ ls -al ~/.ssh
total 28
drwxr-xr-x 1 hehe 197609 0 12月 20 21:57 ./
drwxr-xr-x 1 hehe 197609 0 12月 20 21:45 ../
-rw-r--r-- 1 hehe 197609 3243 12月 20 21:57 id_rsa
-rw-r--r-- 1 hehe 197609 743 12月 20 21:57 id_rsa.pub
-rw-r--r-- 1 hehe 197609 803 12月 18 21:25 known_hosts
4、初始化本地git倉(cāng)庫(kù)
$ git init
Initialized empty Git repository in C:/wamp64/www/other/www/.git/
5、把文件添加到倉(cāng)庫(kù)
$ git add .
warning: LF will be replaced by CRLF in assets/css/colorpicker.css.
The file will have its original line endings in your working directory.
6、把文件提交到倉(cāng)庫(kù)
$ git commit -m "first"
[master 47a15e3] first
warning: LF will be replaced by CRLF in assets/css/colorpicker.css.
The file will have its original line endings in your working directory.
7、把本地庫(kù)git到遠(yuǎn)程生成庫(kù)
hehe@hehe MINGW64 /c/wamp64/www/other/www (master)
$ git remote add origin https://github.com/heheiscool/Keep.git
fatal: remote origin already exists.
8、把本地庫(kù)文件push到遠(yuǎn)程建好庫(kù)中
$ git push -u origin master
Counting objects: 123, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (119/119), done.
Writing objects: 100% (123/123), 1.63 MiB | 29.00 KiB/s, done.
Total 123 (delta 27), reused 0 (delta 0)
remote: Resolving deltas: 100% (27/27), done.
To https://github.com/hehe/Keep.git
[new branch] master -> master
Branch master set up to track remote branch master from origin.
如遠(yuǎn)程提示無(wú)法更新,說(shuō)behind等,確定當(dāng)前代碼是最新的才可以強(qiáng)制推送(注意,不要隨意強(qiáng)制推送)
$ git push -u -f origin master
2018-6-28補(bǔ)充幾點(diǎn):
1、從遠(yuǎn)程庫(kù)強(qiáng)制覆蓋本地庫(kù)
網(wǎng)上是下面的方法
git fetch --all
git reset --hard origin/master
2、關(guān)于pull request(pr)
兩個(gè)分支:master、develop,develop跟master發(fā)送 pr請(qǐng)求,命令操作方式如下:
git clone [email protected]
git checkout master
git pull [email protected] develop
git push origin master
這樣本地庫(kù)master已經(jīng)被提交pr,再上傳到github:
git add .
git commt -m "###"
git push -u origin master
3、創(chuàng)建分支:
git branch newname
切換到分支:
git checkout newname
上傳分支:
git push origin newname
或者上傳當(dāng)前所出分支
git push origin HEAD -u
遠(yuǎn)程刪除分支
git branch -d newname
上述內(nèi)容就是如何理解git的本地操作庫(kù)以及遠(yuǎn)程操作庫(kù),你們學(xué)到知識(shí)或技能了嗎?如果還想學(xué)到更多技能或者豐富自己的知識(shí)儲(chǔ)備,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。
分享名稱:如何理解git的本地操作庫(kù)以及遠(yuǎn)程操作庫(kù)-創(chuàng)新互聯(lián)
轉(zhuǎn)載注明:http://www.jbt999.com/article22/dhcscc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供面包屑導(dǎo)航、標(biāo)簽優(yōu)化、做網(wǎng)站、品牌網(wǎng)站設(shè)計(jì)、手機(jī)網(wǎng)站建設(shè)、電子商務(wù)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:[email protected]。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容