美文网首页
常用git命令

常用git命令

作者: 申浩1992723 | 来源:发表于2018-12-21 11:38 被阅读0次

git常用命令

1.从本地secondtask推送到test2

git push origin secondtask(本地:test2(:前面没空格,有空格的话会删除远程分支并新建一个和本地分支名字相同的远程分支)

2.暂存刚新加的文件

git stash -k -u

3.删除暂存区的记录

git stash drop

4.查看本地和远程的对应关系

git branch -vv

5.第一次提交分支的时候与远程分支建立联系

git push -u origin my_branch 
git branch --set-upstream my_branch origin/my_branch
git push --set-upstream origin/master

6.从远程分支创建并切换到新分支

git checkout -b 本地分支名x origin/远程分支名x
git fetch origin 远程分支名x:本地分支名x  不会自动切换

7.从本地a或者远程a分支检出 指定文件到当前分支

git checkout a(origin a) -- 文件名 

8.rm -f ./.git/index.lock 解决如下问题:

If no other git process is currently running, this probably means a
git process crashed in this repository earlier. Make sure no other git
process is running and remove the file manually to continue.

9.git stash drop 误删解决

* git fsck --lost-found 查看最近删除记录
* git show e2c07caec2b995ba75ce1abd15796c6f1686d532 展示是否是你修改的代码
* git merge e2c07caec2b995ba75ce1abd15796c6f1686d532  合并恢复(直接提交到本地了)

10.删除远程分支

git push origin :old-local-branch-name
git push origin -d BranchName
git push origin --delete BranchName

11.重命名本地分支

git branch -m oldname newname

12.查看git stash内容

git show -p stash@{0}

13.git stash 坑

做修改后先git stash ,然后git pull origin master ,然后git stash pop ,如果出现冲突,stash里面的内容还原回来了,暂存区也还有一份。

14.重命名本地分支

git branch -m oldname newname

15.本地找不到远程分支

git fetch同步一下

16.本地项目推送到远程分支

git remote add origin https://github.com/XuDaojie/Lee.git(远程仓库地址)
git push -u origin master -- 将本地仓库push远程仓库,并将origin设为默认远程仓库

17.git给log设置别名来快速查看友好的log信息

git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -    %C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"

18.删除远程分支后git branch -a 还能看到的问题(显示的是本地仓库的)

git remote show origin 来查看有关于origin的一些信息,包括分支是否tracking。
git remote prune origin

相关文章

  • Git 常用命令详解

    @[TOC](Git 常用命令详解) 1. Git 常用命令 1.1 常用git 命令图表汇总 1.2 配置个人信...

  • git相关教程汇总

    1. git常用命令 git常用命令总结git常用命令讲解 2. git教程相关网站 廖雪峰的git教程猴子都能懂...

  • GIT 版本管理 常用命令

    Git 常用命令流程图 Git常用操作命令: 初始化创建:$ git init //检出仓库:$ git clon...

  • git命令整理

    git常用命令 GIT常用命令备忘:http://stormzhang.com/git/2014/01/27/gi...

  • GIt 操作补充

    常用的git操作命令 常用的git操作命令已经能够满足日常的工作需求 现补充一些高级命令 git branch -...

  • Git

    常用Git命令

  • Git 日常知识

    git常用命令行命令: 1、git 中本地库常用的命令: 本地库的初始化:git init 本地库分支查询:git...

  • Git 常用命令及应用这一篇就够了(新手向)

    1. git 常用命令 1.1 常用命令 1.2 git remote 管理远程仓库 1.3 git r...

  • git操作

    Git原理 Git常用命令

  • GIT 常用命令总结

    GIT 常用命令总结 GIT 初始化命令 命令描述git init初始化本地 git 仓库git config -...

网友评论

      本文标题:常用git命令

      本文链接:https://www.haomeiwen.com/subject/mqrmkqtx.html