版本控制是一種軟體工程技巧,藉以在開發(fā)的過程中,確保由不同人所編輯的統(tǒng)一檔案都得到更新 ,記錄代碼變更。
目前用到的最廣泛的控制器就是SVN和Git。
SVN(Subversion)是集中式管理的版本控制器,Git是分布式管理控制器,這是兩者最本質(zhì)的區(qū)別。
集中式:
分布式:
集中式管理的代表,版本庫存放在中央服務器。只要中央服務器跪了,就無法正常工作了。
分布式管理的代表,每個人都是一個版本庫,通常我們會也有選擇一個“中心倉庫”。彌補了集中式管理的缺陷。
這里我們就根據(jù)開發(fā)需求,以操作為準去學習。
軟件安裝
add-apt-repository ppa:git-core/ppa
apt update
apt install git
注冊github并激活
創(chuàng)建一個項目
命令初體驗,下載項目
git clone URL
配置用戶信息
git config --global user.name "Rock"
git config --global user.email "rockrong1204@aliyun.com"
用PyCharm打開項目并配置Git信息,Git忽略
圖形化更新代碼
圖形化提交代碼
工作區(qū)
暫存區(qū)
本地倉庫
遠程倉庫
分支
git init
git status
git add
git commit
git commit -m "Message"
git log
git diff
git reset
git reset --hard version_code
git rm
git rm -f FileName
git mv
git branch
git branch BranchName
git branch -d BranchName
git checkout
git checkout BranchName
git checkout -b BranchName
git checkout FileName
git merge
git tag
git tag "TAG_name"
git tag -a "TAG_name" version_code
git tag -d TAG_name
git show
git show TagName
git stash
git stash drop
git stash pop
git stash apply
git remote
git rebase
git rebase BranchName
git rebase --continue
git rebase --abort