git入门使用

1 本地仓库
创建一个文件夹,输入git init,这个文件夹将初始化为仓库。
仓库分为三个维度

  • 工作区域
  • 暂存区域
  • 仓库区域

git add file :将会跟踪这个file,将file放入暂存区域。
git commit -m "xxx": 引号的内容尽量用祈使句,暂存区提交到仓库。
以上就是一个提交过程。
win10系统的编码警告:

$ git add version_1.txt
warning: LF will be replaced by CRLF in version_1.txt.
The file will have its original line endings in your working directory

$ git config core.autocrlf
true

$ git config --global core.autocrlf  false

git log:可以查看提交日志,通过git checkout xxx可以回到以前的版本。
git diff:对比工作区与暂存区的差别。
git diff --staged:对比暂存区与仓库的差别。
git reset --hard:清空工作区与暂存区,回到上次提交。

2 分支
git brach:查看分支情况,符号 * 表示所在分支

$ git branch
* master
  test

git checkout test:选择到test分支。
当在分支test,作出更新并提交后,可切换到master分支进行合并。

git checkout master
git merge master test

master分支和test分支都有被修改时,合并时会出现冲突,冲突的提示会增加到源文件,打开源文件,自行查看修改。

3 远程仓库
本地仓库执行命令

git remote add origin https://github.com/xxx/xxx.git

git remote:查看

$ git remote
origin

$ git remote -v
origin  https://github.com/juzhango/git_intro.git (fetch)
origin  https://github.com/juzhango/git_intro.git (push)

git push origin master:将本地文件上传到远程仓库。
git pull origin master:将云端文件拉取到本地。

相关连接
https://www.bilibili.com/video/av414032616?p=1
https://git-scm.com/book/zh/v2

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值