zoukankan      html  css  js  c++  java
  • Git使用笔记

    1. git clone

      git clone http://example.com/test.git,按照提示输入账号密码即可

    2. 第一步clone下来的可能只有master分支,想切换并下载其他分支怎么办?

      方法一:直接git checkout 分支,先git branch -r查看远程分支,然后git checkout 分支

    3. git status: 查看状态,如修改内容后可以看到什么文件什么地方做了修改

    4. git stash: 备份当前的工作区的内容,从最近的一次提交中读取相关内容,让工作区保证和上次提交的内容一致。同时,将当前的工作区内容保存到Git栈中。

      如果误用stash了,想将内容恢复,可以用git stash pop将栈中内容恢复出来

    5. 配置git账号,在git stash/commit时可能提示需要配置账号

      git config --global user.name "your name"  

      git config --global user.email "your_email@youremail.com"  

      这个user name会显示在commit的用户名,不一定是你用的github账号名

    6. 提交,上传

      git add:添加新文件

      push前需要commit:git commit -m "first commit"  

      git push origin master  

    7. 查看commit log:

      git reflog 或者git log, git log内容更全面

    8. 本地回退版本

      git reset --hard 12jhh4

      12jhh4是回退的版本的commit id

    9. 自己的远程仓库回退

      与本地一致git reset --hard 12jhh4

      然后强制推送git push -f

    10. 远程公共分支版本回退方法

      git revert 0ff12sa   //撤销0ff12sa这次提交

      如果有代码冲突,解决掉后新commit 然后提交

  • 相关阅读:
    阿里云通过465端口发送邮件绕过25端口
    阿里云子账号Policy授权规则明细
    蓝鲸cmdb平台架构
    库文件缺失问题修复
    centos7.2中启动polkit服务启动失败
    Linux升级GCC
    Ubuntu18.04服务器使用netplan网络构建桥接kvm虚拟机
    常用服务部署脚本(nodejs,pyenv,go,redis,)
    anaconda安装教程(之前安装过python)
    【PHP】array_unique与array_array_flip
  • 原文地址:https://www.cnblogs.com/tyrionyang/p/6721542.html
Copyright © 2011-2022 走看看