git的使用

来源:互联网 发布:ubuntu登录不进去 编辑:程序博客网 时间:2024/04/27 17:30

重点内容创建项目:在github上创建一个项目test

  1. git配置

    git config –global user.name “WangJunbo”
    git config —global user.email “11@q.com”

  2. 下载代码
    git clone “https://github.com/xiaowang/test.git”
  3. 添加文件
    git add news.txt
    git add . //添加全部修改或新增的文件
  4. 本地提交
    git commit -am “提交测试代码”
  5. 将提交推送到远程服务器
    git push origin master
  6. 修改本地文件
    vim news.txt
  7. 提交修改
    git commit -an “提交修改”
  8. 将提交推送到远程服务器
    git push
  9. 更新本地代码
    git pull
  10. 删除目录
    git rm –cached news.txt
    git commit -m ‘删除news.txt’
    git push origin master

其它

git remote add origin https://github.com/xiaoming/maple.git

  1. 创建分支
    git branch v2
  2. 将分支同步到服务器
    git push origin v2
  3. 切换分支
    git checkout v2
  4. 修改v2分支上的文件
  5. 提交本地修改
    git commit -am “v2修改”
  6. 将提交推送到服务器
    git push origin v2
  7. 查看:v2内容修改, master文件不变
  8. 将v2分支合并到主干
    git checkout master
    git merge v2
    git push
  9. 版本还原
    git checkout v2
    git revert HEAD
  10. 填写描述信息
  11. 查看本地文件内容是否修改
    git push origin v2
  12. 还原到指定版本

在已经存在的文件夹中使用git

  1. git init
  2. git add .
  3. git commit -am ‘初始化messageController2’
  4. git remote add origin
    http://boom.qct.com/messagecontroller2.git
  5. git push -u origin master
0 0
原创粉丝点击