git官網(wǎng):https://git-scm.com
下載=》安裝
證明安裝成功指令:在桌面或者文件中任何地方右鍵出現(xiàn)gitbush githere
使用:(兩種方法)
配合github ?網(wǎng)站:https://github.com/
注冊(cè):記住email
備用郵箱:點(diǎn)頭像-settings-emails
一、詳細(xì)版
a) 把本地的目錄變成git工作區(qū)(倉(cāng)庫(kù))
? ? git init
b) 添加文件到緩存區(qū)
? ? git add 文件名
? ? git add
c) 把文件從緩存區(qū)放去本地倉(cāng)庫(kù)
? ? git commit -m "描述信息必須寫"
? ? 保存第一次需要設(shè)置身份信息
? ? git config --global user.email "you@example.com"
? ? git config --global user.name "Your Name"
? ? 如何查看已經(jīng)配置成功:git config -l
d)往遠(yuǎn)程倉(cāng)庫(kù)中提交代碼
? ?在第一次的時(shí)候需要配置秘鑰
? ?ssh-keygen -t rsa -C '郵箱'
? ?一直回車
? 秘鑰只能用記事本打開
? ?在github上創(chuàng)建遠(yuǎn)程倉(cāng)庫(kù)
? ?按+創(chuàng)建,名字,描述信息,readme不畫鉤
? 添加README.md
? echo "# first" >> README.md
? git add .
? git commit -m "描述信息"
? git remote add origin SSH地址
? git push -u origin master
----------------d步是第一次和遠(yuǎn)程建立聯(lián)系要敲的代碼----------------
git add
git commit
git push
2、秘鑰配置
本地和遠(yuǎn)程通過(guò)秘鑰建立聯(lián)系
ssh-keygen -t rsa -C '郵箱'
身份信息配置
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
----------------------------------------------------------------------------------------
在github中創(chuàng)建項(xiàng)目,勾選下面的小框
在clone的地方復(fù)制地址
在選中的文件夾中點(diǎn)擊gitbush
然后輸入 git clone ssh地址
然后寫項(xiàng)目
上傳:
git add
git commit
git push
輸入賬號(hào)名? 郵箱名
密碼? ? ? ? 登錄密碼
----------------------------------------------------------------------------------------
git pull 從遠(yuǎn)程更新代碼 ?
切記:先更新在提交代碼
==================================================
二、簡(jiǎn)單版
1、用戶認(rèn)證
? ? ?email和用戶名
2、遠(yuǎn)程github
? ? ?設(shè)置秘鑰
? ? ?ssh-keygen -t rsa -C "XXX@ZZZ.com"
? ? ?一般是在c user admin .ssh 注:用記事本打開
? ? ?拿著秘鑰去 settings ssh 新建 title隨便
-----------------------------------------------------------------------
1、github上建立倉(cāng)庫(kù),最后不畫勾
2、按照要求輸入命令? 粘貼復(fù)制
3、初始化文件夾 git init
-----------------------------------------------------------------------
1、 github上建立倉(cāng)庫(kù),最后畫勾
2、粘貼地址:https和ssh地址都可以
3、找個(gè)文件夾git clone ssh地址
4、寫項(xiàng)目
5、git add ? ? ? ? ? ? .文件名 ? ?
6、git commit -m ?"版本描述"(必須寫)
7、git push ? ? ? ? ? 輸入賬號(hào)名密碼
-----------------------------------------------------------------------
上傳代碼之前,先pull一下
========================================
git的一些指令
git在使用的過(guò)程中如果不知道下一步要干什么?
git status=》git目前的狀態(tài)
1、從工作區(qū)到緩存區(qū)
? ? ?git add 文件名
2、把文件從緩存區(qū)移到工作區(qū)
? ? ? git rm --cached 文件名? 這個(gè)用的少
? ? ? git reset HEAD a.txt
3、緩存區(qū)到本地倉(cāng)庫(kù)
? ? ? git commit -m "sss"
4、工作區(qū)刪除文件怎么找回來(lái)(這個(gè)文件必須傳到遠(yuǎn)程倉(cāng)庫(kù)中)
? ? ? git checkout 文件名
5、緩存區(qū)刪除了文件
? ? ? git reset HEAD
? ? ? git checkout 文件名
6、如果本地倉(cāng)庫(kù)都刪除了
? ? ? git log? 查看所有commit的操作日志
? ? ? 找commit ID(黃色的一串)
? ? ? git reset? commit ID (返回到刪除前的那個(gè)版本)
? ? ? git reset HEAD
? ? ? git checkout 文件名