您好,登錄后才能下訂單哦!
g一 git 安裝配置
1.1 安裝
由于大部分工作是在windows下,故下載gitwindows版本,注意要區別32位和64位
使用的是git gui
安裝軟件,默認點擊下一步:
Git-2.7.2-32-bit_setup.1457942412.exe
1.2 生成git bash內容
生成秘鑰:
$ 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里面即可。
使用命令測試,如果出現下面成功,說明已經配置成功了。
$ 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" 提交代碼到暫存區 #git remote add origin git@github:woshiwei201/login_main #git push -u origin master #同步到服務器
具體實例:
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 #查看當前狀態 #git commit -m "no need file" #提交到暫存區 #git push origin master #同步到服務器
具體實例:
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 全局配置信息
#配置全局用戶名參數
git config --global user.name "username"
#配置全局電子郵件地址
git config --global user.email "test@gamil.com"
#查看配置信息
git config --list
3.2 git命令狀態
#git 3個命令狀態
git status
已修改 工作目錄
已暫存 暫存區域 git add
已提交 git目錄 commit
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。