美文网首页
Git Learning Process

Git Learning Process

作者: FlyingPeter | 来源:发表于2018-03-23 00:26 被阅读0次

Learn More,Pratice More,Have a good day!

  • Setup Git.
  • Learn some usual command

教程是Mac的环境,windows不太一样,很幸运找到了入口,没浪费太多的时间。在文件夹下右击选择 Git Bash Here

本地操作

  • touch a.md 新建a.md文件
    所有的命令前面基本都是git 开头
  • git status 查看git状态
  • git init 初始化当前文件夹作为git库
  • git add a.md 提交a.md到缓冲区
  • git rm --cached 移除缓存(没有试过)
  • git commit -m 'first commit' first commit 作为msg提交
  • git log 查看所有的commit log
  • git branch 查看当前所有的分支
  • git branch a 新建a分支
  • git checkout a 切换到a分支
  • git branch -b a 合并上面两步,创建a分支,并且切换到a分支上
  • 合并
    1. git checkout master 切换到master分支
    2. git merge a 将a合并到master分支上来
  • git branch -d a 删除分支a
  • git branch -D a 强制删除a分支
  • git tag v1.0 为当前代码加上v1.0的标签
  • git tag 查看所有的标签
  • git checkout v1.0 切换到v1.0版本

Remote

  • 配置和修改 全局的 用户名&邮箱
  • git config --global user.name 'your name'
  • git config -- global user.email 'your email'
  • 查看用户名&邮箱
  • git config user.name
  • git config user.email

有时候,某个项目需要用特定的用户名和密码提交,到该项目下

git config user.name 'your name'
git config user.email 'your eamil'

本地与GitHub同步

  • git pull origin master 从远程获取最新的代码版本
  • git push origin master 将本地版本更新到远程库origin的 master分支

1.本地没有该项目,从github上clone

git clone https://github.com/FlyingPetter/Walter.git

然后修改文件或者添加文件,需要add commit

git add changefile.nsq
git commit -m 'remark msg'
git push origin master

2.本地已经有test项目,并且commit多次了需要链接到远程库

  1. 在github上新建一个repository test
  2. git remote add origin https://github.com/FlyingPetter/test.git
  3. git push origin master

git remote -v 查看所有的远程库

相关文章

网友评论

      本文标题:Git Learning Process

      本文链接:https://www.haomeiwen.com/subject/pxazqftx.html