• git上传新项目到coding


     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 'xxxx@xx.xx'
    

      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的状态

    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下来 来达到版本一致,否则会报错

    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

  • 相关阅读:
    hibernate03增删改查
    hibernate02环境的搭建
    hibernate01ORM的引入
    20170623_oracle_优化与体系结构
    20170626_oracle_数据库设计
    logging模块
    hashlib模块
    json和pickle模块
    sys模块
    os模块
  • 原文地址:https://www.cnblogs.com/moon3/p/14009024.html
Copyright © 2020-2023  润新知