• git命令


    $ git init  <文件名>

    $ git config --list 

    设置本地仓库用户信息,提交代码

    $ git config [--global] user.name " "

    $ git config [--global] user.email " "

    add到暂存区

    $ git add [file1] [file2] 

    $ git add [dir] 

    $ git add .

            

    $ git  rm [file1][file2] 删除工作区,暂存区还在

    $ git rm --cached [file] 停止追踪,还保留在工作区

    $ git commit -m [message]  提交暂存区到仓库

    $ git commit -a  直接提交工作区到仓库

    $ git log  显示当前分支的版本历史

    $ git log --stat 显示当前分支的commit历史

    $ git diff 显示工作区与暂存区的差异

    $ git archive 生成一个可供分布的压缩包

     转自  https://www.cnblogs.com/chenwolong/p/GIT.html

    git clone

    git clone <版本库的网址> <本地目录名>

    git clone -o jQuery https://github.com/jquery/jquery.git    -o选项可指定remote主机名,默认是origin

       支持多种协议,除了HTTP(s)以外,还支持SSH、Git、本地文件协议等,下面是一些例子。

    1 $ git clone http[s]://example.com/path/to/repo.git/
    2 $ git clone ssh://example.com/path/to/repo.git/
    3 $ git clone git://example.com/path/to/repo.git/
    4 $ git clone /opt/git/project.git 
    5 $ git clone file:///opt/git/project.git
    6 $ git clone ftp[s]://example.com/path/to/repo.git/
    7 $ git clone rsync://example.com/path/to/repo.git/
    git

     SSH协议还有另一种写法。 $ git clone [user@]example.com:path/to/repo.git/

    通常来说,Git协议下载速度最快,SSH协议用于需要用户认证的场合。各种协议优劣的详细讨论请参考官方文档

     

    git remote

    为了便于管理,Git要求每个远程主机都必须指定一个主机名。git remote命令就用于管理主机名。

    git remote 列出所有远程主机名

    git remote -v  另外可查看远程主机的网址

    git remote show <主机名>   列出详细信息

    git remote add    添加远程主机   

           $ git remote add <主机名> <网址>

    git remote rm   删除远程主机

            $ git remote rm <主机名>

    git  remote rename  改名

           $ git remote rename <原主机名> <新主机名>

    git fetch

    一旦远程主机的版本库有了更新(Git术语叫做commit),需要将这些更新取回本地,这时就要用到git fetch命令。

    $ git fetch <远程主机名> <分支名>

    默认情况下,git fetch 取回所有分支(branch)的更新。如果只想取回特定分支的更新,可以指定分支名。

    git branch -r 可以用来查看远程分支

    git branch -a  查看所有分支。

    取回远程主机的更新以后,可以在它的基础上,使用git checkout命令创建一个新的分支。

    $ git checkout -b newBrach origin/master  表示,在origin/master的基础上,创建一个新分支。

    此外,也可以使用git merge命令或者git rebase命令,在本地分支上合并远程分支。

    git pull  

    git pull  命令的作用是,取回远程主机某个分支的更新,再与本地的指定分支合并。它的完整格式稍稍有点复杂。

    $ git pull <远程主机名> <远程分支名>:<本地分支名>

    比如,取回origin主机的next分支,与本地的master分支合并, $ git pull origin next:master

    如果远程分支是与当前分支合并,则冒号后面的部分可以省略。 $ git pull origin next

    等同于先做git fetch,再做git merge

    git push

    git push命令用于将本地分支的更新,推送到远程主机。它的格式与git pull命令相仿。

    $ git push <远程主机名> <本地分支名>:<远程分支名>

    转自 https://blog.csdn.net/qq_42283543/article/details/81530623

  • 相关阅读:
    git命令回退代码并同步到远程仓库
    git拉取远程指定分支
    vue动态绑定样式
    友链
    css三大特性
    CSS的背景background
    元素显示模式(块元素、行内元素、行内块元素)
    CSS复合选择器
    快速生成HTML结构+CSS样式语法
    文本属性
  • 原文地址:https://www.cnblogs.com/scmath/p/9818423.html
Copyright © 2020-2023  润新知