1:coding.net注册帐号,并建立项目.能够将readme.txt打上勾html
2:cd到本机的项目文件夹下 在git中表明workspace linux
3:mac用户用ls -all ,linux用户用ll 或者ls -l查看是否已经存在.git文件夹 该文件夹就是repository(本地的git目录) 若是存在就把它删掉 rm -rf .gitgit
4:设置git的用户名和邮箱. 若是是coding的帐号就使用coding的注册邮箱 和用户名vim
改config的用户名的命令为 bash
git config --global user.name 'xxx'
改邮箱的命令为测试
git config --global user.email 'xxxx@xx.xx'
5:在git中 要将本地项目推送到云端(例如coding)上必需要先加载到本地的index中 而后推送到git工做站上文中提到的repository fetch
git init
git add . #表示添加全部文件 git add index.html #index.html表示某一个文件名
git commit -m 'xxx'
git remote add http://xxxxxxxx
6:添加后可使用status查看git的状态spa
chenjiadeMBP:Questionnaire chenjia$ git status.net
On branch masterhtm
nothing to commit, working tree clean
出现这种表示没有上传到
7:add以后 用commit命令 推送到git工做站也就是上文中提到的repository
git commit -m '说明' #说明中通常填写提交人的姓名和修改的内容 例如我测试一下而已就写个test
8:最关键的一步 到这里千万不能直接网上push 必定要先将coding上的版本pull下来 来达到版本一致,不然会报错
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 +分支名 切换到指定分支
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