zoukankan      html  css  js  c++  java
  • git 常规操作

    git 清除命令  clear !!

     退出vim   q !!!

     取消merge  git merge --abort   注意合并前要讲工作区的内容推上远程或者stach一下  https://blog.csdn.net/weixin_43883776/article/details/85062087

     查看git已操作的命令  git reflog

     根据当前分支创新一个新分支  git checkout -q -b branchName  --no-track HEAD 

     git命令简写:git config alias.spush 'push --recurse-submodules=on-demand'     git supdate            

        git config alias.supdate 'submodule update --remote --merge'         git spush                                                                       

     git status可以查看有哪些文件冲突了  

     HEAD 表示当前版本,也就是最新的提交。上一个版本就是 HEAD^ ,上上一个版本就是 HEAD^^

     往上100个版本写100个 “ ^ ” 比较容易数不过来,所以写成 HEAD~100 。HEAD~2 相当于 HEAD^^ 。

    廖雪峰git:https://www.liaoxuefeng.com/wiki/896043488029600/1216289527823648

    https://github.com/geeeeeeeeek?tab=repositories

    常用命令:https://www.cnblogs.com/springbarley/archive/2012/11/03/2752984.html

    https://blog.csdn.net/buquan4041/article/details/52821919

    1.git init 初始化仓库    git config -l 展示所有global配置        git config --global  user.name  penguin 修改全局配置

    2.制造ssh秘钥  参考:https://www.cnblogs.com/yanglang/p/9563496.html

     ssh-keygen -t rsa -C "your_email@example.com"

     ssh -T git@github.com 

     拿到id_rsa.pub配置到github

    3.添加远程地址  git remote -v 查看  git remote 当前的   git remote add  origin[name]  xxxx[url] 添加远程仓库地址   git remote update -p  更新远程分支   

     git remote rm [name] 删除远程分支

     git branch [name] 创建分支  git branch  查看当前分支  git branch -av 全部分支查看  git branch -d [name] 删除本地分支 git branch -dr [name]删除远程分支  eg:git branch -dr origin/saas-base-October-patch

     git branch -D [name] 强制删除(合并过的分支)

     git checkout [branch name] 切换分支  git checkout -b [branch name] 切换并新建分支  git checkout --filename  弹出commit或者暂存区里弹出

    4.git log 查看commit记录  git log -p [filename]查看某个文件  git reflog 查看命令记录   git blame [file]查看文件修改   git show [commitID] 查看commit修改

    git log --graph --pretty=oneline --abbrev-commit  查看commit图

    4.1 git commit --amend 修改commit     

      git reset HEAD <file> 取消暂存  git reset --soft HEAD^ 撤回commit(不撤回git add)   --mixed  撤回到原来但不修改工作空间的修改   --hard连工作空间的都撤回

      git checkout -- <file> 取消工作区文件修改   git checkout -- . 

    https://www.jianshu.com/p/3bd53278eb88

    5.提示没有拉去的跟踪信息  git pull origin dev           git pull <远程主机名> <远程分支名>:<本地分支名>

    6.提示没有提交的地址  git push -u origin dev    -u== --set-upstream

    git push -u origin dev_xin 提交到远程

    git remote update -p   跟新远程分支

    git branch -m dev_xinfafang_depend_tag20190925-V1.2.7  hotfix_xinfafang_tagV1.2.7

    git branch -m old_branch new_branch # Rename branch locally 
    git push origin :old_branch # Delete the old branch 
    git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
    

      

    git branch --set-upstream-to=origin/<branch> dev_xinfafang_depend_tag20190925-V1.2.7   创建一个分支关联到远程分支
    git branch --set-upstream-to=origin/remote_branch  your_branch  
     
    查看各个分支最后一次提交: $ git branch -v
    查看哪些分支合并入当前分支: $ git branch –merged
    查看哪些分支未合并入当前分支: $ git branch –no-merged
    
    
    

      

    修改远程分支名称:
    (1)git branch -m  oldBranchName  newBranchName
    git push --delete  (-d)  origin  oldBranchName  
    git push origin newBranchName:newBranchName
    git  push -u  origin  newBranchName
    
    (2)git checkout -b newBranchName
    git push origin newBranchName:newBranchName
    git  push -u  origin  newBranchName
    
    

    7.git pull和git fetch的区别 

    参考:https://blog.csdn.net/a19881029/article/details/42245955

    https://blog.csdn.net/weixin_41975655/article/details/82887273

    # 方法一
    $ git fetch origin master                #从远程的origin仓库的master分支下载代码到本地的origin maste
    $ git log -p master.. origin/master      #比较本地的仓库和远程参考的区别
    $ git merge origin/master                #把远程下载下来的代码合并到本地仓库,远程的和本地的合并

    # 方法二
    $ git fetch origin master:temp           #从远程的origin仓库的master分支下载到本地并新建一个分支temp
    $ git diff temp                          #比较master分支和temp分支的不同
    $ git merge temp                         #合并temp分支到master分支
    $ git branch -d temp                     #删除temp

    8.git config --global core.autocrlf  true

    为了保证文件的换行符是以安全的方法,避免windows与unix的换行符混用的情况,最好也加上这么一句

    9.

    UNDO
    Discard all local changes in your working
    directory
    $ git reset --hard HEAD
    Discard local changes in a specific file
    $ git checkout HEAD <file>
    Revert a commit (by producing a new commit
    with contrary changes)
    $ git revert <commit>
    Reset your HEAD pointer to a previous commit
    …and discard all changes since then
    $ git reset --hard <commit>
    …and preserve all changes as unstaged
    changes
    $ git reset <commit>
    …and preserve uncommitted local changes
    $ git reset --keep <commit>
    
    
  • 相关阅读:
    Moss2010 部署命令
    socket形象描述
    Android UI 的更新
    android AIDL 进程间通信
    中文设置成粗体的方法
    android 主件之 Service
    android activity
    拦截Activity的后退键处理
    android 解析json数据格式
    防止事件导致的oncreate的多次调用
  • 原文地址:https://www.cnblogs.com/little-ab/p/11397428.html
Copyright © 2011-2022 走看看