Git進階-2-本地配置GIt
阿新 • • 發佈:2020-12-23
技術標籤:Git
1 配置本地使用者和郵箱
git config --global 命名 '值'; 可以新增新值 如 git config --global user.name "你的使用者名稱" git config --global user.email "你的郵箱" git config –list 檢視配置列表資訊 git config --global --unset 命名 刪除配置值 如:git config --global --unset core.editor git config --global core.editor 'vim'
$ git config --list diff.astextplain.textconv=astextplain filter.lfs.clean=git-lfs clean -- %f filter.lfs.smudge=git-lfs smudge -- %f filter.lfs.process=git-lfs filter-process filter.lfs.required=true http.sslbackend=openssl http.sslcainfo=D:/appach/Git/mingw64/ssl/certs/ca-bundle.crt core.autocrlf=true core.fscache=true core.symlinks=false core.quotepath=false core.editor="C:\\Program Files\\Notepad++\\notepad++.exe" -multiInst -notabbar -nosession -noPlugin pull.rebase=false credential.helper=manager gui.encoding=utf-8 i18n.commitencoding=utf-8 i18n.logoutputencoding=utf-8 svn.pathnameencoding=utf-8 core.quotepath=false core.editor=vim gui.encoding=utf-8 i18n.commitencoding=utf-8 i18n.logoutputencoding=utf-8 svn.pathnameencoding=utf-8 user.email=郵箱 user.name=使用者名稱 core.repositoryformatversion=0 core.filemode=false core.bare=false core.logallrefupdates=true core.symlinks=false core.ignorecase=true core.quotepath=false remote.origin.url=連線的git地址 remote.origin.fetch=+refs/heads/*:refs/remotes/origin/* branch.master.remote=origin branch.master.merge=refs/heads/master
2 建立SSH Key
由於你的本地 Git 倉庫和 GitHub 倉庫之間的傳輸是通過SSH加密的,所以我們需要配置驗證資訊:
git輸入命令
$ ssh-keygen -t rsa -C “使用者名稱”或者郵箱 (連續按三次Enter)
可以在本地使用者目錄下檢視到.ssh資料夾,在該資料夾下存在三個檔案
id_rsa.pub 檢視此檔案,直接複製祕鑰
開啟GitHub 點選頭像->settings->SSH and GPG keys->New SSH key
將id_rsa.pub複製的公鑰複製進去
驗證是否配置成功:
ssh -T [email protected]
驗證時可能讓你輸入YES。
成功提示 : 如果出現Hi han1202012! You’ve successfully authenticated, but GitHub does not provide shell access. 就說明配置成功, 可以連線上GitHub;
3 Git上傳檔案基本步驟
建立本地倉庫
git init 或者 git init 檔案目錄
新增,提交檔案到本地倉庫
git add . 或者 git add <filename>
git commit -m "備註comment"
將本地檔案推送到伺服器
git remote add origin https://git地址/使用者名稱/專案名.git
git push origin master
如果push時遇到無許可權,沒有提示輸入使用者名稱和密碼直接403的問題
git remote add origin https://使用者名稱:密碼@git地址/使用者名稱/專案名.git