溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

git基本用戶

發(fā)布時間:2020-07-18 17:39:14 來源:網(wǎng)絡(luò) 閱讀:274 作者:woshiwei201 欄目:開發(fā)技術(shù)

 g一 git 安裝配置

   1.1 安裝

   由于大部分工作是在windows下,故下載gitwindows版本,注意要區(qū)別32位和64位

使用的是git gui

   安裝軟件,默認(rèn)點擊下一步:

   Git-2.7.2-32-bit_setup.1457942412.exe


  1.2 生成git bash內(nèi)容

生成秘鑰:

$ ssh-keygen.exe -t
rsa -C "woshiwei@gmail.com"
Generating
public/private rsa key pair.
Enter file in which
to save the key (/c/Users/chenwei/.ssh/id_rsa):
Enter passphrase
(empty for no passphrase):
Enter same
passphrase again:
Your identification
has been saved in /c/Users/chenwei/.ssh/id_rsa.
Your public key has
been saved in /c/Users/chenwei/.ssh/id_rsa.pub.
The key fingerprint
is:
SHA256:8qa01nxrfl+2KcmdpIUcMu9vtGEYobyI×××JTZkxIak
woshiwei@gmail.com
The key's randomart
p_w_picpath is:
+---[RSA 2048]----+
|       .+==     
|
|       o.+. 
.   |
|      o . . . . 
|
|     E +  
= o   |
|      o S . * = 
|
|     . = . . = * |
|      ooo  
o O *|
|     ..+o o .* Bo|
|     .o 
+oo .=+ |
+----[SHA256]-----+
 
chenwei@vbear
MINGW32 ~
$

 

然后把生成的/c/Users/chenwei/.ssh/id_rsa.pub 拷貝到 github里面的<user>--<setting>--<SSH and GPG keys>,添加到ssh key里面即可。

 

使用命令測試,如果出現(xiàn)下面成功,說明已經(jīng)配置成功了。

$ ssh git@github.com
PTY allocation
request failed on channel 0
Hi woshiwei! You've successfully authenticated, but GitHub does not
provide shell access.
Connection to
github.com closed.


二 維護常見操作

2.1 克隆git庫

#git clone xxxx
cd login_main
D:\chenwei\login_main>git
clone https://github.com/woshiwei201/login_main.git
Cloning into
'login_main'...
remote: Counting
objects: 3, done.
remote: Total 3
(delta 0), reused 3 (delta 0), pack-reused 0
Unpacking objects:
100% (3/3), done.
Checking
connectivity... done.


2.2 更新提交代碼

#git add xxxx   添加需要更新的文件
#git commit -m "first update"   提交代碼到暫存區(qū)
#git remote add origin git@github:woshiwei201/login_main   
#git push -u origin master   #同步到服務(wù)器


具體實例:

D:\chenwei\login_main\login_main>git
add *
 
D:\chenwei\login_main\login_main>git
commit -m "add login_main"
[master a872fab] add
login_main
 4 files changed, 127 insertions(+)
 create mode 100644 README.txt
 create mode 100644 login_main_v1.1.py
 create mode 100644 login_user.jpg
 create mode 100644 user_config.conf
 
D:\chenwei\login_main\login_main>git
remote add origin https://github.com/woshiw
ei201/login_main.git
fatal: remote origin
already exists.
 
D:\chenwei\login_main\login_main>git
push -u origin master
 ounting objects: 6, done.
Delta compression
using up to 8 threads.
Compressing objects:
100% (6/6), done.
Writing objects:
100% (6/6), 88.18 KiB | 0 bytes/s, done.
Total 6 (delta 0),
reused 0 (delta 0)
To https://github.com/woshiwei201/login_main.git
   eb8b592..a872fab  master -> master
Branch master set up
to track remote branch master from origin.

 

#查看地址:


https://github.com/woshiwei201/login_main


2.3 刪除文件

#git
rm hello.md    #輸入想要刪除的文件
#git status      #查看當(dāng)前狀態(tài)
#git commit -m "no need file"   #提交到暫存區(qū)
#git push origin master     #同步到服務(wù)器


具體實例:

 
D:\chenwei\login_main\login_main>git
status
On branch master
Your branch is
up-to-date with 'origin/master'.
Changes to be
committed:
  (use "git reset HEAD
<file>..." to unstage)
 
        deleted:    hello.md
 
D:\chenwei\login_main\login_main>git
commit -m "no need file"
[master 3950a7f] no
need file
 1 file changed, 1 deletion(-)
 delete mode 100644 hello.md
 
D:\chenwei\login_main\login_main>git
push origin master
Counting objects: 2,
done.
Delta compression
using up to 8 threads.
Compressing objects:
100% (2/2), done.
Writing objects:
100% (2/2), 218 bytes | 0 bytes/s, done.
Total 2 (delta 1),
reused 0 (delta 0)
To https://github.com/woshiwei201/login_main.git
   af9dbc6..3950a7f  master -> master
 
D:\chenwei\login_main\login_main>
#登錄界面驗證
https://github.com/woshiwei201/login_main


2.4 更新代碼到本地



三 常見的配置信息

3.1 全局配置信息

#配置全局用戶名參數(shù)

git config --global user.name "username"


#配置全局電子郵件地址

git config --global user.email "test@gamil.com"


#查看配置信息

git config --list


3.2 git命令狀態(tài)

#git 3個命令狀態(tài)

git status

已修改   工作目錄

已暫存   暫存區(qū)域   git add

已提交   git目錄     commit



向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI