1:coding.net注冊賬號,并創建專案.可以將readme.txt打上勾
2:cd到本機的專案檔案夾下 在git中代表workspace
3:mac用戶用ls -all ,linux用戶用ll 或者ls -l查看是否已經存在.git檔案夾 該檔案夾就是repository(本地的git目錄) 如果存在就把它刪掉 rm -rf .git
4:設定git的用戶名和郵箱. 如果是coding的賬號就使用coding的注冊郵箱 和用戶名
改config的用戶名的命令為
git config --global user.name 'xxx'
改郵箱的命令為
git config --global user.email '[email protected]'
5:在git中 要將本地專案推送到云端(例如coding)上必須要先加載到本地的index中 然后推送到git作業站上文中提到的repository
git init
git add . #表示添加所有檔案 git add index.html #index.html表示某一個檔案名
git commit -m 'xxx'
git remote add http://xxxxxxxx
6:添加后可以使用status查看git的狀態
<style>p.p1 { margin: 0; font: 14px Menlo; color: rgba(40, 254, 20, 1); background-color: rgba(0, 0, 0, 0.9) } span.s1 { font-variant-ligatures: no-common-ligatures }</style>chenjiadeMBP:Questionnaire chenjia$ git status
On branch master
nothing to commit, working tree clean
出現這種表示沒有上傳到
7:add之后 用commit命令 推送到git作業站也就是上文中提到的repository
git commit -m '說明' #說明中一般填寫提交人的姓名和修改的內容 例如我測驗一下而已就寫個test
8:最關鍵的一步 到這里千萬不能直接網上push 一定要先將coding上的版本pull下來 來達到版本一致,否則會報錯
<style>p.p1 { margin: 0; font: 14px Menlo; color: rgba(40, 254, 20, 1); background-color: rgba(0, 0, 0, 0.9) } span.s1 { font-variant-ligatures: no-common-ligatures }</style>To https://git.coding.net/cjkk/QuestionNaire.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://git.coding.net/cjkk/QuestionNaire.git'
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 https://git.coding.net/cjkk/QuestionNaire.git --allow-unrelated-histories #那個https的地址是自己的coding目錄的網址
9:最后一步了
git push --set-upstream https://git.coding.net/cjkk/QuestionNaire.git master #同上換下地址
最后更改分支問題了
和把大象放到冰箱里一樣 需要三步
1.打開冰箱
git checkout -b dev #創建并切換到dev分支 可以自己改分支名
介紹一下git branch 查看分支狀態 git branch + 名字 創建分支名 git checkout +分支名 切換到指定分支
<style>p.p1 { margin: 0; font: 14px Menlo; color: rgba(40, 254, 20, 1); background-color: rgba(0, 0, 0, 0.9) } p.p2 { margin: 0; font: 14px Menlo; color: rgba(52, 188, 38, 1); background-color: rgba(0, 0, 0, 0.9) } span.s1 { font-variant-ligatures: no-common-ligatures } span.s2 { font-variant-ligatures: no-common-ligatures; color: rgba(40, 254, 20, 1) }</style>chenjiadeMBP:Questionnaire chenjia$ git branch
* master
chenjiadeMBP:Questionnaire chenjia$ git branch ccc
chenjiadeMBP:Questionnaire chenjia$ git branch
ccc
* master
chenjiadeMBP:Questionnaire chenjia$ git checkout ccc
Switched to branch 'ccc'
chenjiadeMBP:Questionnaire chenjia$ git branch
* ccc
master
2: 把大象放進去 當前已經是在分支下了,可以進行正常的增刪改查操作,都不會影響主分支 類似linux虛擬機的快照功能和古老的系統備份功能
vim test.txt #創建一個test.txt 自己隨便寫點東西在里面 git add test.txt git commit -m '測驗分支功能'
這樣就是在分支中完成了
3:關門 不關門浪費電 當在dev分支下把階段任務完成時,直接切回master分支,并把master分支指向dev 之后dev就可以刪掉了
git checkout master #切換到master分支 git merge dev #merge合并的意思 將master和dev合并,原理就是將master走到dev那 git branch -d dev #洗掉分支命令
over
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/225261.html
標籤:其他
下一篇:專案微管理21 - 互聯
