Gitee初探
公司開始用git處理提交了,因為是給我們搭建好的環境,直接用repo提交了,初次在windows下用git的時候難免遇到一些問題。現在記錄一下。
git和svn的區別就不說了。為什麼不用github,也是因為不想太麻煩。
# 背景
STM32F401的主控,初次用了STM32CUBE MX IDE開發,但是編輯器環境不好,所以後面用了 visual studio code。
# 搭建
- 首先在git上註冊一個賬號。新建一個倉庫。略。
- 本地下載git 64bit.exe,全程下一步安裝。
- 用visualcode開啟命令提示行 Ctrl + Alt + ~ ,輸入git確定是否有安裝成功。
- 配置Git提交的名稱和郵箱,此時配置資訊在 C:\Users\[username]\.gitconfig 檔案裡面可以看到
> git config --global user.name "xxxx" > git config --global user.email "xxxx@xxx.com"
- 生成ssh公鑰,輸入下列命令,一路回車,此時生成的金鑰資訊在 C:\Users\[username]\.ssh 資料夾中可以看到
> ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (C:\Users\[username]/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in C:\Users\[username]/.ssh/id_rsa. Your public key has been saved in C:\Users\[username]/.ssh/id_rsa.pub. The key fingerprint is: SHA256:va###lue###value###value### [username]@[計算機名稱] The key's randomart image is: | | | | | | | | | | | | | | | | | | +----[SHA256]-----+
- 保留金鑰資訊,避免每次都需要輸入密碼
> git config --global credential.helper store
- 將 C:\Users\[username]\.ssh\id_rsa.pub 檔案內容全部拷貝在gitee的ssh公鑰裡面
- 在gitee新建一個倉庫
設定-倉庫空間管理-新建倉庫 - 切換到工程所在目錄,初始化本地倉庫
> git init
-
關聯遠端倉庫
> git remote add origin https://gitee.com/使用者個性地址/倉庫地址
-
新增所有檔案並且提交。
> git add . > git commit -m "註釋" > git push origin master
在git add . 時報 fatal: adding files failed ,可以通過下指令處理
> git add --ignore-errors .
push時需要輸入帳號密碼:
在push時可能會報錯:> git push origin master To https://gitee.com/個性地址/倉庫地址 ! [rejected] master -> master (fetch first) error: failed to push some refs to 'https://gitee.com/個性地址/倉庫地址' hint: Updates were rejected because the remote contains work that you do hint: not have locally. This is usually caused by another repository pushing hint: to the same ref. You may want to first integrate the remote changes hint: (e.g., 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details.
可以通過傳送下述命令:
> git pull origin master > git push origin master
此時還是報錯:
> git push origin master To https://gitee.com/個性地址/倉庫地址 ! [rejected] master -> master (non-fast-forward) error: failed to push some refs to 'https://gitee.com/個性地址/倉庫地址' hint: Updates were rejected because the tip of your current branch is behind hint: its remote counterpart. Integrate the remote changes (e.g. hint: 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details.
強制推送:
> git push -f origin master Enumerating objects: 426, done. Counting objects: 100% (426/426), done. Delta compression using up to 16 threads Compressing objects: 100% (401/401), done. Writing objects: 100% (426/426), 6.70 MiB | 3.97 MiB/s, done. Total 426 (delta 119), reused 0 (delta 0), pack-reused 0 remote: Resolving deltas: 100% (119/119), done. remote: Powered by GITEE.COM [GNK-5.0] remote: error: GE007: Your push would publish a private email address. remote: You can make your email public or disable this protection by visiting: remote: https://gitee.com/profile/emails remote: error: hook declined to update refs/heads/master To https://gitee.com/個性地址/倉庫地址 ! [remote rejected] master -> master (hook declined)
可以看到是郵箱問題,因為我隱藏了私人郵箱,取消第二個勾選即可。
相關文章
- Git&GiteeGitee
- Gitee使用教程Gitee
- Typora + Gitee + PicGoGiteePicGo
- git-giteeGitee
- gitee 教程學習Gitee
- vscode中使用giteeVSCodeGitee
- Gitee 碼雲的使用Gitee
- gitee 學習筆記Gitee筆記
- gitee程式碼版本回退Gitee
- 【第十一篇】- Git GiteeGitee
- 如何使用 Gitee 搭建圖床Gitee圖床
- 關於前端vsCode的gitee管理前端VSCodeGitee
- 突發!Gitee 圖床,廢了!Gitee圖床
- angr初探
- Vue初探Vue
- Docker初探Docker
- 初探 Recompose
- jsbridge初探JS
- Nginx 初探Nginx
- Deno 初探
- ELK初探
- Quartz初探quartz
- 初探IndexedDBIndex
- Redis初探Redis
- MapDB初探
- Puppeteer 初探
- gRPC 初探RPC
- ## RATreeView 初探View
- 初探Firewalld
- Serverless初探Server
- Mobx 初探
- 初探PWA
- 初探TCPTCP
- jQuery初探jQuery
- 初探 BaconJSJS
- 初探 TypeScriptTypeScript
- ECharts 初探Echarts
- Quantum 初探