美文网首页
git 常用整理

git 常用整理

作者: 大猿媛 | 来源:发表于2019-10-14 17:40 被阅读0次

Git初始化项目

  • git 初始化

1.Git init: 创建仓库并初始化——>终端 cd到代码根目录——>git init初始化仓库,add,commit——>重点[git remote add origin 你的远程库地址] ——>获取远程库同步git pull --rebase origin master——>提交git push -u origin mast;如果Git pull报错: refusing to merge unrelated histories的解决办法,执行下面的命令:git pull origin master --allow-unrelated-histories就可以了。参考:(https://www.cnblogs.com/xiangxinhouse/p/8254120.html)

  • 本地配置git环境

2.本地配置git环境,终端创建sshkey: ssh-keygen -t rsa -C "********@163.com”,将创建好的ssh-key,粘贴到git账户里的设置ssh的地方

*. 终端认证关联账户

git config --global user.name “XXXXX"
git config --global user.email “******@163.com"

常用基础

1 创建repository,复制链接clone本地,添加内容,add . commit push

2 首次push,git push --set-upstream origin master 或者 git push origin master : master

3 git pull 下拉内容

4 创建分支并切换到此分支: git checkout -b newBranch

5 创建分支:git branch newBranch 切换到此分支:git checkout newBranch

6 将新分支合并到master分支 git checkout master,合并: git merge newBranch

7 删除分支: git branch -d newBranch

8 查看分支 :git branch

远程分支管理:

0、更新远程分支列表: git remote update origin --prune

1、本地分支推送到远端:git push origin <local_branch_name>:<remote_branch_name> 如:git push origin 2.6.0 : 2.6.0

2、删除: git push origin :develop local_branch_name为空就表示删除

3、clone远程分支: git clone -b <branch name> <repository >

git多个账户:

1、当使用git config --global user.name “XXXX"

              git config --global user.email “********@163.com”关联的是全局账户,在user文件夹里会有一个.gitconfig文件,可以打开看看

2、若需要另一个账户管理其他的git工程,可以在工程文件夹下,终端使用命令:

   git config  user.name “XXX"

   git config  user.email “******@163.com”

3、查看当前git工程目录下的账户 git config --list

bogon:AudioPlayerManager Hammer$ git config --list
credential.helper=osxkeychain
user.name=chaozhangkong       //全局账户
[user.email=juniorchen@yingshibao.com](mailto:user.email=juniorchen@yingshibao.com)
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
core.ignorecase=true
core.precomposeunicode=true
remote.origin.url=https://github.com/xxxx/*****.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
user.name=XXXX         //此工程的账户
[user.email=******@163.com](mailto:user.email=******@163.com)
bogon:AudioPlayerManager Hammer$

日志log

1.查看最新的commit

git show

2.查看指定commit hashID的所有修改:

git show commitId

3.查看某次commit中具体某个文件的修改:

git show commitId fileName

Tag标签:

1、创建标签: git tag v2.7.0 ,带描述的标签:git tag -a v2.7.0 -m “version2.7.0 released"
2、查看标签: git tag 或 git tag #, git show tagName(git show v2.7.0)查看标签描述
3、删除标签:git tag -d v2.7.0
4、将本地标签推送到远程: git push origin v2.7.0,或者,一次性推送全部尚未推送到远程的本地标签:git push origin —tags
5、删除远程标签tag: 先删本地:git tag -d v2.7.0, 远程:git push origin :refs/tags/v2.7.0
6、创建本地tag分支:git checkout -b branch_name tag_name
7、切换当指定分支 : git checkout v2.7.0

不常见问题

  1. git push 超过100M解决办法
1 方法一:可以以命令的形式直接git bash 中直接:git config http.postBuffer 524288000(500M)
对于部分非二进制的文件这样的可以解决单个文件过大的问题
如果方法一不可行,git push还是说的是文件过大,那么只有删除这个二进制文件了,原因可看码云
删除文件后还是同样的提示的话,就直接下面的方法了
2 方法二  git bash 中命令:git filter-branch -f --index-filter "git rm -rf --cached --ignore-unmatch folder" -- --all
其中folder可以修改成你的文件名字(也就是报错中的文件名字)
  1. git pull 提示fatal: refusing to merge unrelated histories
git pull origin master --allow-unrelated-histories

廖雪峰的官方网站:

http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/

相关文章

  • Git 常用命令整理

    Git 常用命令整理 Git 删除本地分支 git branch -D/-d branchID 例如 Git 批量...

  • 2018-07-20

    git常用命令整理 //删除远程分支 git push origin : git push origin --de...

  • 常用git整理

    约定 : repository_url: git项目地址 e.g.: https://XXX/test.git[h...

  • git 常用整理

    Git初始化项目 git 初始化 1.Git init: 创建仓库并初始化——>终端 cd到代码根目录——>git...

  • git基本命令

    整理下git常用的命令 1. 安装git(Linux环境) sudo apt-get install git 2....

  • Git常用命令整理

    一、Git 常用命令整理 命令 简要说明 git branch 查看本地所有分支 git status 查看...

  • git 常用命令

    记不住整理下, Git 常用命令 git branch 查看本地所有分支 git status 查看当前状态 gi...

  • 常用 Git 命令

    Git最常用的命令示意图 下面是我整理的常用 Git 命令清单。几个专用名词的译名如下。 Workspace:工作...

  • git简单命令手册

    常用的git命令整理 基本操作 与远程仓库的交互 rebase(变基) git pull 相当于git fetch...

  • Git 常用命令

    整理了一下在测试过程中常用的Git 命令,持续更新....... 1.git branch git branch ...

网友评论

      本文标题:git 常用整理

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