QT繪製時鐘和進度條
目錄
- 基本配置
- 建立本地倉庫
- 推送到遠端倉庫
1 基本配置
1.1 配置基本資訊
git config --global user.name “itcast”
git config --global user.email “[email protected]”
1.2 檢視配置資訊
git config --global user.name
git config --globa user.email
1.3 設定常用指令別名
-
開啟使用者目錄,建立 .bashrc 檔案
部分windows系統不允許使用者建立點號開頭的檔案,可以開啟gitBash,執行touch ~/.bashrc
-
在 .bashrc 檔案中輸入如下內容:
#用於輸出git提交日誌
alias git-log='git log --pretty=oneline --all --graph --abbrev-commit'
#用於輸出當前目錄所有檔案及基本資訊
alias ll='ls -al'
- 開啟gitBash,執行
source ~/.bashrc
1.4 解決GitBash亂碼問題
- 開啟GitBash執行下面命令
git config --global core.quotepath false
- ${git_home}/etc/bash.bashrc 檔案最後加入下面兩行
export LANG="zh_CN.UTF-8" export LC_ALL="zh_CN.UTF-8"
2 建立本地倉庫
2.1 基本步驟
-
git init
(初始化) -
git add 單個檔名
或git add .
(工作區 --> 暫存區) -
git commit -m '註釋內容'
(暫存區 --> 本地倉庫)
2.2 版本控制
-
git status
(檢視的修改的狀態(暫存區、工作區)) -
git-log
(檢視日誌) -
git log [option]
(檢視日誌)
options- all 顯示所有分支
- pretty=oneline 將提交資訊顯示為一行
- abbrev-commit 使得輸出的commitId更簡短
- graph 以圖的形式顯示
-
git reset --hard commitID
(版本回退,commitID可使用git-log檢視) -
git reflog
(檢視已經刪除的提交記錄) -
根目錄建立 .gitignore 檔案 新增檔案至忽略列表
# no .a files
*.a
# but do track lib.a, even though you're ignoring .a files above
!lib.a
# only ignore the TODO file in the current directory, not subdir/TODO
/TODO
# ignore all files in the build/ directory
build/
# ignore doc/notes.txt, but not doc/server/arch.txt
doc/*.txt
# ignore all .pdf files in the doc/ directory
doc/**/*.pdf
2.3 分支
-
git branch 分支名
(建立分支) -
git checkout 分支名
(切換到分支)git checkout -b 分支名
(建立並切換分支) -
git merge 分支名
(合併分支,前提是已經git checkout master) -
如果有衝突,手動解決衝突.
-
git branch -d 分支名
(刪除分支)git branch -D 分支名
(強制刪除分支)
3 Git遠端倉庫
3.1 Gitee
-
生成SSH公鑰
ssh-keygen -t rsa
- 不斷回車
-
獲取公鑰
cat ~/.ssh/id_rsa.pub
-
配置公鑰
-
驗證是否配置成功
ssh -T [email protected]
-
新增遠端倉庫
git remote add origin [email protected]:......
-
檢視遠端倉庫
git remote
-
推送到遠端倉庫
-
git push --set-upstream origin master
(--set-upstream 建立本地與遠端的聯絡(首次)) -
git push
(非首次)
-
-
檢視本地分支與遠端分支的關聯關係
git branch -vv
-
克隆
-
git clone <倉庫路徑> [本地目錄]
(倉庫路徑使用SSH地址)
-
-
抓取:將倉庫裡的更新都抓取到本地,但不合並
git fetch [remote name] [branch name]
-
拉取:將遠端倉庫的修改拉到本地並自動進行合併,等同於fetch+merge
git pull [remote name] [branch name]
- fetch和pull 如果不指定遠端名稱和分支名,則抓取所有並更新當前分支
在一段時間,A、B使用者修改了同一個檔案,且修改了同一行位置的程式碼,此時會發生合併衝突。A使用者在本地修改程式碼後優先推送到遠端倉庫,此時B使用者在本地修訂程式碼,提交到本地倉庫後,也需要推送到遠端倉庫,此時B使用者晚於A使用者,故需要先拉取遠端倉庫的提交,經過合併後才能推送到遠端分支。
3.2 GitHub
配置ssh金鑰的方法:https://www.cnblogs.com/Maurice-code/p/10531303.html
git clone 出現fatal: unable to access ‘https://github.com 的解決方法:將命令列的https改為git即可.