git笔记

常用命令总览

$ git
usage: git [--version] [--help] [-C <path>] [-c name=value]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p | --paginate | --no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           <command> [<args>]

These are common Git commands used in various situations:

start a working area (see also: git help tutorial)
   clone      Clone a repository into a new directory
   init       Create an empty Git repository or reinitialize an existing one

work on the current change (see also: git help everyday)
   add        Add file contents to the index
   mv         Move or rename a file, a directory, or a symlink
   reset      Reset current HEAD to the specified state
   rm         Remove files from the working tree and from the index

examine the history and state (see also: git help revisions)
   bisect     Use binary search to find the commit that introduced a bug
   grep       Print lines matching a pattern
   log        Show commit logs
   show       Show various types of objects
   status     Show the working tree status

grow, mark and tweak your common history
   branch     List, create, or delete branches
   checkout   Switch branches or restore working tree files
   commit     Record changes to the repository
   diff       Show changes between commits, commit and working tree, etc
   merge      Join two or more development histories together
   rebase     Reapply commits on top of another base tip
   tag        Create, list, delete or verify a tag object signed with GPG

collaborate (see also: git help workflows)
   fetch      Download objects and refs from another repository
   pull       Fetch from and integrate with another repository or a local branch
   push       Update remote refs along with associated objects

'git help -a' and 'git help -g' list available subcommands and some
concept guides. See 'git help <command>' or 'git help <concept>'
to read about a specific subcommand or concept.

常用命令

  • 初始化配置
    git config --global user.name "Your Name"
    git config --global user.email "email@example.com"

  • 创建仓库
    git init

  • 远程仓库

    • git remote -v显示关联的远程仓库
    • git remote add origin git@github.com:classQ/test.git关联远程仓库
    • git clone git@github.com:classQ/test.git克隆远程仓库
  • 远程协作

    • git pull origin master 获取远程仓库代码
    • git push orgin master推送到远程仓库(为了避免冲突,push前先pull)
  • 分支

    • git branch -b a 创建分支a
    • git checkout a 切换到分支a
    • git checkout -b a 创建并切换分支a
    • git branch -d a 删除分支a
    • git merge a 合并分支
  • tag

    我们在客户端开发的时候经常有版本的概念,比如v1.0、v1.1之类的,不同的版本肯定对应不同的代码,所以我一般要给我们的代码加上标签,这样假设v1.1版本出了一个新bug,但是又不晓得v1.0是不是有这个bug,有了标签就可以顺利切换到v1.0的代码,重新打个包测试了。

    • git tag显示当前创建了哪些tag
    • git tag v1.0创建tag v1.0

远程仓库github

添加SSH key到github中

  1. 生成rsa公钥与私钥("C:\Users\Administrator.ssh[id_rsa.pub|id_rsa]")
$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/Administrator/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/Administrator/.ssh/id_rsa.
Your public key has been saved in /c/Users/Administrator/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:J4Up2SmaEeYElOex+O0s+cLmtb/ArfLnYT2mvm5mCOI Administrator@LS--20160418PSW
The key's randomart image is:
+---[RSA 2048]----+
| .oo+            |
|  .+o. o +       |
|   +oo+ = .      |
|  . o+ o .       |
|   .o.  S .      |
|  . o... +       |
| . o =+.+ +      |
|  E B.+==+ .     |
|   o.*=XOo       |
+----[SHA256]-----+
  1. 将公钥(id_rsa.pub的内容)添加到github中去

在github创建仓库

克隆仓库、关联仓库、提交更新、推送更新、

最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 本文章是学习廖雪峰老师的《GIT教程》的笔记。 一.安装GIT 因为Git是分布式版本控制系统,所以,每个机器都必...
    海棠的那个大鱼哟阅读 303评论 0赞 0
  • 一.Git简介 Git是世界上最先进的分布式版本控制系统,相对于SVN这样的集中式版本控制系统,Git不需要“中央...
    ahuustcly阅读 874评论 0赞 0
  • 对于一个新的包括submodule的项目调用以下命令即可 或者 配置 首先是配置帐号信息 ssh -T git@g...
    brownfeng阅读 598评论 0赞 0
  • GIT笔记: 1. 工作区(Working Directory)和版本库(Repository) 说明: 工作区就...
    hello大象阅读 375评论 0赞 0
  • 今天出门有些晚了,平时的109路人特别少,少到以为自己坐上了包车!当我还在庆幸我刚现在站牌车就来了的时候,后面跟着...
    有点小脾气阅读 300评论 0赞 0

友情链接更多精彩内容