您当前的位置: 首页 > 学无止境 > 心得笔记 网站首页心得笔记
09 探密.git目录
发布时间:2020-07-05 14:33:32编辑:雪饮阅读()
切换分支
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web (branch3)
$ git branch
branch2
* branch3
master
temp
可以看到当前在branch3分支上,那么我们切换到master分支上如
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web (branch3)
$ git checkout master
Switched to branch 'master'
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web (master)
$ git branch
branch2
branch3
* master
temp
.git/config中文件内容修改也可以达到配置git用户的效果
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web (master)
$ git config --local --list
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
core.symlinks=false
core.ignorecase=true
remote.origin.url=https://github.com/xueyin220807/web.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
gui.wmstate=normal
gui.geometry=1061x563+128+128 233 255
user.name=xy220807
user.email=1509272975@qq.com
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web (master)
$ vi .git/config
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web (master)
$ git config --local --list
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
core.symlinks=false
core.ignorecase=true
remote.origin.url=https://github.com/xueyin220807/web.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
gui.wmstate=normal
gui.geometry=1061x563+128+128 233 255
user.name=xy2208072
user.email=1509272975@qq.com
通过命令配置用户后也会自动存储到.git/config中
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web (master)
$ git config --local user.name 'xy220807'
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web (master)
$ cat .git/config
[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
symlinks = false
ignorecase = true
[remote "origin"]
url = https://github.com/xueyin220807/web.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
[gui]
wmstate = normal
geometry = 1061x563+128+128 233 255
[user]
name = xy220807
email = 1509272975@qq.com
分支与里程碑
分支与里程碑在.git/refs/下的heads和tags中存储
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web (master)
$ ls -al .git/refs
total 4
drwxr-xr-x 1 xy 197121 0 6月 5 23:36 ./
drwxr-xr-x 1 xy 197121 0 7月 5 12:36 ../
drwxr-xr-x 1 xy 197121 0 7月 4 17:28 heads/
drwxr-xr-x 1 xy 197121 0 6月 5 23:36 remotes/
drwxr-xr-x 1 xy 197121 0 7月 5 10:39 tags/
我们可以看到分支列表
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web (master)
$ ls -al .git/refs/heads
total 4
drwxr-xr-x 1 xy 197121 0 7月 4 17:28 ./
drwxr-xr-x 1 xy 197121 0 6月 5 23:36 ../
-rw-r--r-- 1 xy 197121 41 7月 4 17:06 branch2
-rw-r--r-- 1 xy 197121 41 7月 4 17:28 branch3
-rw-r--r-- 1 xy 197121 41 7月 4 11:27 master
-rw-r--r-- 1 xy 197121 41 7月 4 17:05 temp
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web (master)
$ cat .git/refs/heads/master
48142d39abcd7f51c16d4eb50127445af496d056
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web (master)
$ git cat-file -t 48142d39abcd7f
commit
这个是查看文件类型的命令,传参时候只需要传递日志id的局部值即可,除非这个局部值有重复则需要改提供为更长长度的局部值。
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web (master)
$ git branch -av
branch2 48142d3 modified index.html
branch3 b07d738 modify 2.txt
* master 48142d3 [ahead 1] modified index.html
temp 48142d3 modified index.html
remotes/origin/HEAD -> origin/master
remotes/origin/master b0babbd index
你会发现这里版本列表中master这个分支目前这个日志id也是只取了局部。
接下来看看里程碑
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web (master)
$ ls -la .git/refs/tags/
total 1
drwxr-xr-x 1 xy 197121 0 7月 5 10:39 ./
drwxr-xr-x 1 xy 197121 0 6月 5 23:36 ../
-rw-r--r-- 1 xy 197121 41 7月 5 10:39 从这里创建的branch2分支
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web (master)
$ cat .git/refs/tags/从这里创建的branch2分支
5a0cbdf852eac26a3eba7c50829befd1e52904e1
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web (master)
$ git cat-file -t 5a0cbdf852ea
commit
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web (master)
$ git cat-file -p 5a0cbdf852ea
tree 4ac8245e14176c5ce263f2f348605525977a7995
parent 7b60a5a85e10b8086dd90c74350256dace976f0f
author xueyin220807 <1509272975@qq.com> 1591369573 +0800
committer GitHub <noreply@github.com> 1591369573 +0800
gpgsig -----BEGIN PGP SIGNATURE-----
wsBcBAABCAAQBQJe2l9lCRBK7hj4Ov3rIwAAdHIIAFJWYS2obqX30rg9tHHSpIGL
CMWqeEPv6FHemFJaLHYLW4jLkZc6jWf5Fz3erMaD8D+EJyr4u6S/ZEagO7ye70zl
A9iF/rutErm8fpLrl74JBw1LWjtv159sA814nXGEZTFPyJqT4rJOv+LPx/qs6LHY
xpybhKKagRQ18iKFyXphPxknRfhPeOu6EG+qMFQLAm0R+whTX6XJli32mYiSuMlq
RmeIWW4kSnbVpNsabr9zai3OQJGjNGujrqh0mSvjCwtjyhJ9VJ1nK8LFhjSQEEwy
l0s6NhlQqFPg4koAn/yi9rDvdzQRH5GHcQDd7cx3nMogcq9SjhjAGYZNEwjtlco=
=ba5a
-----END PGP SIGNATURE-----
Update index.md
这里p参数可以直接看到文件内容
.git/objects
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web (branch2)
$ ls -la .git/objects/
total 16
drwxr-xr-x 1 xy 197121 0 7月 4 17:28 ./
drwxr-xr-x 1 xy 197121 0 7月 5 13:03 ../
drwxr-xr-x 1 xy 197121 0 6月 5 23:37 03/
drwxr-xr-x 1 xy 197121 0 6月 5 23:37 06/
drwxr-xr-x 1 xy 197121 0 7月 4 17:26 0a/
drwxr-xr-x 1 xy 197121 0 6月 5 23:37 0e/
drwxr-xr-x 1 xy 197121 0 6月 6 09:37 10/
drwxr-xr-x 1 xy 197121 0 7月 4 17:18 13/
drwxr-xr-x 1 xy 197121 0 6月 5 23:37 14/
drwxr-xr-x 1 xy 197121 0 6月 5 23:37 1f/
drwxr-xr-x 1 xy 197121 0 6月 5 23:37 20/
drwxr-xr-x 1 xy 197121 0 6月 5 23:37 23/
drwxr-xr-x 1 xy 197121 0 6月 5 23:37 32/
drwxr-xr-x 1 xy 197121 0 7月 4 17:12 38/
drwxr-xr-x 1 xy 197121 0 6月 5 23:37 3b/
drwxr-xr-x 1 xy 197121 0 6月 5 23:37 40/
drwxr-xr-x 1 xy 197121 0 6月 5 23:37 42/
drwxr-xr-x 1 xy 197121 0 6月 5 23:37 46/
drwxr-xr-x 1 xy 197121 0 7月 4 11:27 48/
drwxr-xr-x 1 xy 197121 0 6月 5 23:37 5f/
drwxr-xr-x 1 xy 197121 0 6月 5 23:37 6f/
drwxr-xr-x 1 xy 197121 0 6月 5 23:37 76/
drwxr-xr-x 1 xy 197121 0 6月 5 23:37 78/
drwxr-xr-x 1 xy 197121 0 6月 5 23:37 79/
drwxr-xr-x 1 xy 197121 0 6月 6 09:37 7c/
drwxr-xr-x 1 xy 197121 0 7月 4 17:18 87/
drwxr-xr-x 1 xy 197121 0 6月 5 23:37 8e/
drwxr-xr-x 1 xy 197121 0 7月 4 17:26 92/
drwxr-xr-x 1 xy 197121 0 7月 4 17:12 95/
drwxr-xr-x 1 xy 197121 0 6月 5 23:37 a5/
drwxr-xr-x 1 xy 197121 0 7月 4 17:28 b0/
drwxr-xr-x 1 xy 197121 0 7月 4 17:28 bd/
drwxr-xr-x 1 xy 197121 0 7月 4 17:28 bf/
drwxr-xr-x 1 xy 197121 0 6月 5 23:37 c5/
drwxr-xr-x 1 xy 197121 0 6月 5 23:37 cf/
drwxr-xr-x 1 xy 197121 0 6月 5 23:37 df/
drwxr-xr-x 1 xy 197121 0 6月 5 23:37 e0/
drwxr-xr-x 1 xy 197121 0 6月 5 23:37 e1/
drwxr-xr-x 1 xy 197121 0 6月 5 23:37 e4/
drwxr-xr-x 1 xy 197121 0 7月 4 17:18 e6/
drwxr-xr-x 1 xy 197121 0 6月 5 23:37 eb/
drwxr-xr-x 1 xy 197121 0 6月 5 23:37 ed/
drwxr-xr-x 1 xy 197121 0 6月 5 23:37 f2/
drwxr-xr-x 1 xy 197121 0 6月 5 23:37 f3/
drwxr-xr-x 1 xy 197121 0 6月 5 23:37 fb/
drwxr-xr-x 1 xy 197121 0 6月 5 23:36 info/
drwxr-xr-x 1 xy 197121 0 6月 5 23:36 pack/
这里有pack目录和如上所示的两个字母的目录,而pack目录中则是对如上面的两个字母的目录的打包。
资源拼接
我们再次查看如上的fb目录
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web (branch2)
$ ls -la .git/objects/fb
total 5
drwxr-xr-x 1 xy 197121 0 6月 5 23:37 ./
drwxr-xr-x 1 xy 197121 0 7月 4 17:28 ../
-r--r--r-- 1 xy 197121 161 6月 5 23:37 73adb7a27517731051d98818fa90c721219f33
则我们要看该目录中的某个文件如上面显示的73adb开头的这个文件类型,则如
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web (branch2)
$ git cat-file -t fb73adb7a27517731051d98818fa90c721219f33
Tree
也就是用目录名拼接文件名就是完整的日志文件id咯。
另外这个文件是tree文件,所以-p查看内容则就是一个文件列表,即目录内容
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web (branch2)
$ git cat-file -p fb73adb7a27517731051d98818fa90c721219f33
100644 blob ed8f593470af4bbe2ae386985dab57c8cb2b5efb app.f73030f9.js
100644 blob e19aed9552148b760f0d9c02844f7ec36e38a784 app.f73030f9.js.map
100644 blob 32c9b76efe5d49620f2ccf42a9be42dda0b612ba chunk-vendors.0396140b.js
100644 blob 8eea8e0372ce00a42304689d52c5780c2c288acb chunk-vendors.0396140b.js.map
那么接下来查看这个app开头的这个blob文件则如
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web (branch2)
$ git cat-file -p ed8f593470af4bbe2ae386985dab57c8cb2b5efb
(function(e){function t(t){for(var n,l,s=t[0],i=t[1],u=t[2],p=0,f=[];p<s.length;p++)l=s[p],Object.prototype.hasOwnProperty.call(o,l)&&o[l]&&f.push(o[l][0]),o[l]=0;for(n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i[n]);c&&c(t);while(f.length)f.shift()();return a.push.apply(a,u||[]),r()}function r(){for(var e,t=0;t<a.length;t++){for(var r=a[t],n=!0,s=1;s<r.length;s++){var i=r[s];0!==o[i]&&(n=!1)}n&&(a.splice(t--,1),e=l(l.s=r[0]))}return e}var n={},o={app:0},a=[];function l(t){if(n[t])return n[t].exports;var r=n[t]={i:t,l:!1,exports:{}};return e[t].call(r.exports,r,r.exports,l),r.l=!0,r.exports}l.m=e,l.c=n,l.d=function(e,t,r){l.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},l.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l.t=function(e,t){if(1&t&&(e=l(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(l.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)l.d(r,n,function(t){return e[t]}.bind(null,n));return r},l.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return l.d(t,"a",t),t},l.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},l.p="/";var s=window["webpackJsonp"]=window["webpackJsonp"]||[],i=s.push.bind(s);s.push=t,s=s.slice();for(var u=0;u<s.length;u++)t(s[u]);var c=i;a.push([0,"chunk-vendors"]),r()})({0:function(e,t,r){e.exports=r("56d7")},"034f":function(e,t,r){"use strict";var n=r("85ec"),o=r.n(n);o.a},"1a4e":function(e,t,r){"use strict";var n=r("bd18"),o=r.n(n);o.a},"56d7":function(e,t,r){"use strict";r.r(t);r("e260"),r("e6cf"),r("cca6"),r("a79d");var n=r("2b0e"),o=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{attrs:{id:"app"}},[n("img",{attrs:{alt:"Vue logo",src:r("cf05")}}),n("HelloWorld",{attrs:{msg:"Welcome to Your Vue.js App"}})],1)},a=[],l=function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("div",{staticClass:"hello"},[r("h1",[e._v(e._s(e.msg))]),e._m(0),r("h3",[e._v("Installed CLI Plugins")]),e._m(1),r("h3",[e._v("Essential Links")]),e._m(2),r("h3",[e._v("Ecosystem")]),e._m(3)])},s=[function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("p",[e._v(" For a guide and recipes on how to configure / customize this project,"),r("br"),e._v(" check out the "),r("a",{attrs:{href:"https://cli.vuejs.org",target:"_blank",rel:"noopener"}},[e._v("vue-cli documentation")]),e._v(". ")])},function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("ul",[r("li",[r("a",{attrs:{href:"https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel",target:"_blank",rel:"noopener"}},[e._v("babel")])]),r("li",[r("a",{attrs:{href:"https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-pwa",target:"_blank",rel:"noopener"}},[e._v("pwa")])])])},function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("ul",[r("li",[r("a",{attrs:{href:"https://vuejs.org",target:"_blank",rel:"noopener"}},[e._v("Core Docs")])]),r("li",[r("a",{attrs:{href:"https://forum.vuejs.org",target:"_blank",rel:"noopener"}},[e._v("Forum")])]),r("li",[r("a",{attrs:{href:"https://chat.vuejs.org",target:"_blank",rel:"noopener"}},[e._v("Community Chat")])]),r("li",[r("a",{attrs:{href:"https://twitter.com/vuejs",target:"_blank",rel:"noopener"}},[e._v("Twitter")])]),r("li",[r("a",{attrs:{href:"https://news.vuejs.org",target:"_blank",rel:"noopener"}},[e._v("News")])])])},function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("ul",[r("li",[r("a",{attrs:{href:"https://router.vuejs.org",target:"_blank",rel:"noopener"}},[e._v("vue-router")])]),r("li",[r("a",{attrs:{href:"https://vuex.vuejs.org",target:"_blank",rel:"noopener"}},[e._v("vuex")])]),r("li",[r("a",{attrs:{href:"https://github.com/vuejs/vue-devtools#vue-devtools",target:"_blank",rel:"noopener"}},[e._v("vue-devtools")])]),r("li",[r("a",{attrs:{href:"https://vue-loader.vuejs.org",target:"_blank",rel:"noopener"}},[e._v("vue-loader")])]),r("li",[r("a",{attrs:{href:"https://github.com/vuejs/awesome-vue",target:"_blank",rel:"noopener"}},[e._v("awesome-vue")])])])}],i={name:"HelloWorld",props:{msg:String}},u=i,c=(r("1a4e"),r("2877")),p=Object(c["a"])(u,l,s,!1,null,"776ca2e7",null),f=p.exports,v={name:"App",components:{HelloWorld:f},created:function(){this.$axios.get("http://vue.gaojiupan.cn/api/getthumimages/0").then((function(e){console.log(e)})),this.$axios.get("http://vue.gaojiupan.cn/api/getnewslist").then((function(e){console.log(e)}))}},g=v,h=(r("034f"),Object(c["a"])(g,o,a,!1,null,null,null)),d=h.exports,_=r("9483");Object(_["a"])("".concat("/","service-worker.js?")+Date.now(),{ready:function(){console.log("App is being served from cache by a service worker.\nFor more details, visit https://goo.gl/AFskqB")},registered:function(){console.log("Service worker has been registered.")},cached:function(){console.log("Content has been cached for offline use.")},updatefound:function(){console.log("New content is downloading.")},updated:function(){console.log("New content is available; please refresh.")},offline:function(){console.log("No internet connection found. App is running in offline mode.")},error:function(e){console.error("Error during service worker registration:",e)}});var b=r("bc3a"),m=r.n(b);n["a"].prototype.$axios=m.a,n["a"].config.productionTip=!1,new n["a"]({render:function(e){return e(d)}}).$mount("#app")},"85ec":function(e,t,r){},bd18:function(e,t,r){},cf05:function(e,t,r){e.exports=r.p+"img/logo.82b9c7a5.png"}});
//# sourceMappingURL=app.f73030f9.js.map
关键字词:git,.git目录