记录:git学习简单总结

前言

git学习的简单笔记

教程

   菜鸟教程(https://www.runoob.com/git/git-tutorial.html)

   廖雪峰 (https://www.liaoxuefeng.com/wiki/896043488029600)

简介

   Git 是 Linus Torvalds 为了帮助管理 Linux 内核开发而开发的一个开放源码的版本控制软件。

   Git 与常用的版本控制工具 CVS, Subversion 等不同,它采用了分布式版本库的方式

常用命令

   git init 当前目录

   git init newrepo 指定目录

   基本操作

   git status

   git diff

   git diff --cached

   git add *.c

   git add README

   git commit -m "init"

   git clone <repo> <directory>

   撤销修改

   before add: git checkout -- <filename>

   after add: git reset HEAD <filename>

   删除

   git rm <file>

   git rm -f <file>

   git rm --cached <file>

   分支管理

   git branch

   git branch <branch>

   git branch -d <branchname>

   git switch <branch> 

   日志

   git log --oneline --graph

   远程仓库

   生成密钥对:ssh-keygen -t rsa -C "youremail@example.com"

   git remote add <shortname> <url>

   git push -u <shortname> <branchname>

   git remote rename <old> <new>

   git fetch <shortname> <branchname>

   git merge <shortname>/<branchname>

   git pull origin hello 将分支拉下来

在本地创建和远程分支对应的分支,使用git checkout -b branch-name origin/branch-name,本地和远程分支的名称最好一致;

建立本地分支和远程分支的关联,使用git branch --set-upstream branch-name origin/branch-name;

总结

比较了一下两个教程,感觉还是廖雪峰老师的教程讲的好一些,多人协作部分挺好的。

但是感觉仍然不够深入,现在对各个命令的理解还是比较肤浅。进一步,可能需要从英文的说明文档入手。

现在有个问题,就是我能否在本地通过git 命令来操作github远程仓库,使远程仓库新建branch,而不必通过github网页进行操作,有待进一步验证。

而且,对分支的merge仍有些生疏,有待练习。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值