当前位置:   article > 正文

Git学习_refs/heads/master

refs/heads/master

.git目录

$cd .git ; tree -L 1
|-- HEAD         # 记录当前处在哪个分支里
|-- config       # 项目的配置信息,git config命令会改动它
|-- description  # 项目的描述信息
|-- hooks/       # 系统默认钩子脚本目录
|-- index        # 索引文件
|-- logs/        # 各个refs的历史信息
|-- objects/     # Git本地仓库的所有对象 (commits, trees, blobs, tags)
|-- refs/        # 标识每个分支指向了哪个提交(commit)。
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

目录文件详解

cat .git/HEAD

# HEAD文件里只有下面一行,表示当前所在的分支(这里是master分支)
ref: refs/heads/master
  • 1
  • 2

cat .git/config

# 基本配置
[core]
	repositoryformatversion = 0
	filemode = false
	bare = false
	logallrefupdates = true
	symlinks = false
	ignorecase = true
# 远程版本库
[remote "origin"]
	url = https://github.com/xxx/git-start.git
	fetch = +refs/heads/*:refs/remotes/origin/*
# 本地版本与远程版本映射关系
[branch "master"]
	remote = origin
	merge = refs/heads/master
[branch "develop"]
	remote = origin
	merge = refs/heads/develop
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19

常用命令

# 查看本地分支
git branch
# 查看远程分支
git branch -r
# 查看所有分支
git branch -a

# 从当前所在分支新建一个分支
git checkout -b local(新分支名)

# 将新建分支推送到远程
git push --set-upstream origin local(分支名)

# 删除本地分支
git branch -d local(分支名) 
# 删除远程分支
git push origin --delete local(分支名)

# 本地多次提交合并
git rebase –i HEAD~4(次数)

# 分支合并 (master分支合并v1.0.0)
git merge origin v1.0.0

# 退到/进到 指定commit的sha码
git reset --hard commit_id
# 强推到远程
git push origin HEAD --force

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/412263
推荐阅读
相关标签
  

闽ICP备14008679号