Finalised
This commit is contained in:
parent
5022169c08
commit
d8288cef57
2 changed files with 246 additions and 283 deletions
256
GitDeepDive.org
256
GitDeepDive.org
|
@ -86,8 +86,9 @@
|
||||||
- Submarining :: the structure of a commit, "Content Addressable Filesystem", git objects
|
- Submarining :: the structure of a commit, "Content Addressable Filesystem", git objects
|
||||||
- Unmanned submersibles :: the reflog, =fsck= and =gc=, finding and dealing with specific git objects
|
- Unmanned submersibles :: the reflog, =fsck= and =gc=, finding and dealing with specific git objects
|
||||||
** About Éibhear Ó hAnluain
|
** About Éibhear Ó hAnluain
|
||||||
- Solutions Architect
|
- Enterprise and Solutions Architect
|
||||||
+ eibhear.geo@gmail.com
|
+ e-mail: [[mailto:eibhear.geo@gmail.com][eibhear.geo@gmail.com]]
|
||||||
|
+ [matrix]: [[https://matrix.to/#/@eibhear:matrix.gibiris.org][@eibhear:matrix.gibiris.org]], [[https://matrix.to/#/@eibhear:matrix.org][@eibhear:matrix.org]]
|
||||||
- Software engineer since 1994
|
- Software engineer since 1994
|
||||||
- Using revision control since 1994: _subversion_, _git_,
|
- Using revision control since 1994: _subversion_, _git_,
|
||||||
_IBM/Rational/Atria ClearCase_, _RCS_, _VSS_, _CVS_, _Serena
|
_IBM/Rational/Atria ClearCase_, _RCS_, _VSS_, _CVS_, _Serena
|
||||||
|
@ -107,7 +108,8 @@
|
||||||
git config --local --list
|
git config --local --list
|
||||||
git config --global --list
|
git config --global --list
|
||||||
git config --system --list
|
git config --system --list
|
||||||
git config [--system|--global|--local] <key> <value>
|
git config [--system|--global|--local] <key> \
|
||||||
|
<value>
|
||||||
git config -e
|
git config -e
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
** =fetch= and =merge=, not =pull=
|
** =fetch= and =merge=, not =pull=
|
||||||
|
@ -196,24 +198,16 @@
|
||||||
#+REVEAL_HTML: </div>
|
#+REVEAL_HTML: </div>
|
||||||
|
|
||||||
#+REVEAL_HTML: </div>
|
#+REVEAL_HTML: </div>
|
||||||
** Merging appraoches: Decision tree
|
** Merging approaches: Decision tree
|
||||||
file:./images/merge-decision-tree-chart.png
|
file:./images/merge-decision-tree-chart.png
|
||||||
* The Shallows
|
* The Shallows
|
||||||
**
|
Let's go a little deeper
|
||||||
*** A little deeper :B_block:BMCOL:
|
|
||||||
:PROPERTIES:
|
|
||||||
:BEAMER_col: 0.9
|
|
||||||
:BEAMER_env: block
|
|
||||||
:END:
|
|
||||||
file:./images/Naufragio_por_Gustavo_Gerdel.jpg
|
|
||||||
|
|
||||||
#+latex: {\tiny
|
#+CAPTION: By Ggerdel - Foto de: Gustavo Gerdel (BAB Buceo) [[https://creativecommons.org/licenses/by-sa/4.0][CC BY-SA 4.0]], via Wikimedia Commons
|
||||||
By Ggerdel - Foto de: Gustavo Gerdel (BAB Buceo) [CC BY-SA 4.0 (https://creativecommons.org/licenses/by-sa/4.0)], via Wikimedia Commons
|
#+ATTR_HTML: :width 70%
|
||||||
#+latex: }
|
file:./images/Naufragio_por_Gustavo_Gerdel.jpg
|
||||||
** Refs
|
** Refs -- branches
|
||||||
*** Refs
|
#+BEGIN_SRC shell
|
||||||
- Branches
|
|
||||||
#+BEGIN_SRC
|
|
||||||
$ ls -1 .git/refs/heads/*
|
$ ls -1 .git/refs/heads/*
|
||||||
.git/refs/heads/gitlab_10.x_upgrade
|
.git/refs/heads/gitlab_10.x_upgrade
|
||||||
.git/refs/heads/gitlab-ce-8.17
|
.git/refs/heads/gitlab-ce-8.17
|
||||||
|
@ -223,10 +217,9 @@
|
||||||
$ cat .git/refs/heads/gitlab-ce-8.17
|
$ cat .git/refs/heads/gitlab-ce-8.17
|
||||||
c63767d0b9b520f36a533237624dfaa1256b463c
|
c63767d0b9b520f36a533237624dfaa1256b463c
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
** Refs
|
** Refs -- tags
|
||||||
*** Refs
|
|
||||||
- tags
|
- tags
|
||||||
#+BEGIN_SRC
|
#+BEGIN_SRC shell
|
||||||
$ ls -1 .git/refs/tags/
|
$ ls -1 .git/refs/tags/
|
||||||
gitlab-cookbook-for-10.7.3
|
gitlab-cookbook-for-10.7.3
|
||||||
gitlab-cookbook-initial
|
gitlab-cookbook-initial
|
||||||
|
@ -236,14 +229,12 @@
|
||||||
f16b12027cef7052e09f3a483ace55999800ea5b
|
f16b12027cef7052e09f3a483ace55999800ea5b
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
- =HEAD=
|
- =HEAD=
|
||||||
#+BEGIN_SRC
|
#+BEGIN_SRC shell
|
||||||
$ cat .git/HEAD
|
$ cat .git/HEAD
|
||||||
ref: refs/heads/gitlab_10.x_upgrade
|
ref: refs/heads/gitlab_10.x_upgrade
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
** Refs
|
** Refs -- remotes
|
||||||
*** Refs
|
#+BEGIN_SRC shell
|
||||||
- remotes
|
|
||||||
#+BEGIN_SRC
|
|
||||||
$ ls -1 .git/refs/remotes/origin/*
|
$ ls -1 .git/refs/remotes/origin/*
|
||||||
.git/refs/remotes/origin/ara_test
|
.git/refs/remotes/origin/ara_test
|
||||||
.git/refs/remotes/origin/brjones_aci_network
|
.git/refs/remotes/origin/brjones_aci_network
|
||||||
|
@ -257,18 +248,16 @@
|
||||||
7130b7ee374ad9f7ba784ec0b0d0b86dc99f41d4
|
7130b7ee374ad9f7ba784ec0b0d0b86dc99f41d4
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
** HEAD
|
** HEAD
|
||||||
*** HEAD
|
|
||||||
- =HEAD= is a ref that points to where the commit currently checked out
|
- =HEAD= is a ref that points to where the commit currently checked out
|
||||||
- =HEAD= in a remote repository usually points to the default branch
|
- =HEAD= in a remote repository usually points to the default branch
|
||||||
|
|
||||||
#+BEGIN_SRC
|
#+BEGIN_SRC shell
|
||||||
$ cat .git/HEAD
|
$ cat .git/HEAD
|
||||||
ref: refs/heads/master
|
ref: refs/heads/master
|
||||||
$ cat .git/refs/remotes/origin/HEAD
|
$ cat .git/refs/remotes/origin/HEAD
|
||||||
ref: refs/remotes/origin/REL2_0
|
ref: refs/remotes/origin/REL2_0
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
** Annotated tags
|
** Annotated tags 1/2
|
||||||
*** Annotated tags
|
|
||||||
- A normal tag is just a "ref", pointing to a commit.
|
- A normal tag is just a "ref", pointing to a commit.
|
||||||
#+BEGIN_SRC shell
|
#+BEGIN_SRC shell
|
||||||
git tag Rel1.0 Rel1
|
git tag Rel1.0 Rel1
|
||||||
|
@ -276,226 +265,199 @@
|
||||||
git cat-file -t $(cat .git/refs/tags/Rel1.0)
|
git cat-file -t $(cat .git/refs/tags/Rel1.0)
|
||||||
git cat-file -p $(cat .git/refs/tags/Rel1.0)
|
git cat-file -p $(cat .git/refs/tags/Rel1.0)
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
- *Caveat*: tags and branches use different namespaces, so
|
- Caveat :: tags and branches use different namespaces, so
|
||||||
temptation to tag the =Rel1= branch with =Rel1= would be
|
temptation to tag the =Rel1= branch with =Rel1= would be
|
||||||
high. However, this causes confusion for many git tools, so
|
high. However, this causes confusion for many git tools, so
|
||||||
should be avoided.
|
should be avoided.
|
||||||
** Annotated tags
|
** Annotated tags 2/2
|
||||||
*** Annotated tags
|
- An annotated tag is a separate git object, that records
|
||||||
- An annotated tag is a separate git object, that records information specfic to the tag:
|
information specfic to the tag:
|
||||||
+ Tag name; date; tagger; commit it's pointing to
|
+ Tag name; date; tagger; commit it's pointing to
|
||||||
- Advice is for annotated tags to be used for significant announcements/releases/snaphots.
|
- Advice is for annotated tags to be used for significant
|
||||||
|
announcements/releases/snaphots.
|
||||||
#+BEGIN_SRC shell
|
#+BEGIN_SRC shell
|
||||||
git tag -a -m "Formal release of 1.0" \
|
git tag -a -m "Formal release of 1.0" Rel1.0.prod Rel1
|
||||||
Rel1.0.prod Rel1
|
|
||||||
cat .git/refs/tags/Rel1.0.prod
|
cat .git/refs/tags/Rel1.0.prod
|
||||||
git cat-file -t $(cat .git/refs/tags/Rel1.0.prod)
|
git cat-file -t $(cat .git/refs/tags/Rel1.0.prod)
|
||||||
git cat-file -p $(cat .git/refs/tags/Rel1.0.prod)
|
git cat-file -p $(cat .git/refs/tags/Rel1.0.prod)
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
** blame
|
** blame
|
||||||
*** =blame=
|
- Identifies the commit, commit author and date for each line in a
|
||||||
- Identifies the commit, commit author and date for each line in a file.
|
file.
|
||||||
- Doesn't give information for lines that have been removed or replaced.
|
- Doesn't give information for lines that have been removed or
|
||||||
|
replaced.
|
||||||
** Tag and commit signing
|
** Tag and commit signing
|
||||||
*** Tag and commit signing and verification
|
|
||||||
- PGP/GnuPG (=gpg=): expects familiarity with public/private key encryption.
|
- PGP/GnuPG (=gpg=): expects familiarity with public/private key encryption.
|
||||||
- Sign tags and commits with private key to assure integrity
|
- Sign tags and commits with private key to assure integrity
|
||||||
#+BEGIN_SRC shell
|
#+BEGIN_SRC shell
|
||||||
git commit -Seibhear.geo@gmail.com \
|
git commit -Seibhear.geo@gmail.com -m \
|
||||||
-m "Update to information.md"
|
"Update to information.md"
|
||||||
git cat-file -p $(cat .git/refs/heads/master)
|
git cat-file -p $(cat .git/refs/heads/master)
|
||||||
git tag -s -u eibhear.geo@gmail.com \
|
git tag -s -u eibhear.geo@gmail.com -m "Release 2." Rel2.0 \
|
||||||
-m "Release 2." Rel2.0 Rel2
|
Rel2
|
||||||
git cat-file -p $(cat .git/refs/tags/Rel2.0)
|
git cat-file -p $(cat .git/refs/tags/Rel2.0)
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
- Verify commits and tags with public key
|
- Verify commits and tags with public key
|
||||||
#+BEGIN_SRC
|
#+BEGIN_SRC shell
|
||||||
git tag -v Rel2.0
|
git tag -v Rel2.0
|
||||||
git log --show-signature -1
|
git log --show-signature -1
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
* The Continental shelf
|
* The Continental shelf
|
||||||
**
|
|
||||||
*** Switch on the Sonar :B_block:BMCOL:
|
|
||||||
:PROPERTIES:
|
|
||||||
:BEAMER_col: 0.9
|
|
||||||
:BEAMER_env: block
|
|
||||||
:END:
|
|
||||||
file:./images/Loligo_vulgaris.jpg
|
|
||||||
|
|
||||||
#+latex: {\tiny
|
#+CAPTION: By © Hans Hillewaert, CC BY-SA 4.0, https://commons.wikimedia.org/w/index.php?curid=385705
|
||||||
By © Hans Hillewaert, CC BY-SA 4.0, https://commons.wikimedia.org/w/index.php?curid=385705
|
#+ATTR_HTML: :width 70%
|
||||||
#+latex: }
|
file:./images/Loligo_vulgaris.jpg
|
||||||
** Git Objects -- blobs
|
** Git Objects -- blobs
|
||||||
*** Blob (file)
|
- A file
|
||||||
A file
|
|
||||||
#+BEGIN_SRC shell
|
#+BEGIN_SRC shell
|
||||||
$ cat ~/.profile | git hash-object --stdin
|
$ cat ~/.profile | git hash-object \
|
||||||
|
--stdin
|
||||||
c9db4591825bd7a918df686ff04aeb3a87d3bda0
|
c9db4591825bd7a918df686ff04aeb3a87d3bda0
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
** Git Objects -- trees
|
** Git Objects -- trees
|
||||||
*** Tree
|
- A listing of files and other tree objects containing the
|
||||||
A listing of files and other tree objects containing the
|
|
||||||
following information on each: access mode (similar to UNIX
|
following information on each: access mode (similar to UNIX
|
||||||
permissions); type (e.g. =tree=, =blob=); SHA1; file/directory
|
permissions); type (e.g. =tree=, =blob=); SHA1; file/directory
|
||||||
name
|
name
|
||||||
#+BEGIN_SRC shell
|
#+BEGIN_SRC shell
|
||||||
$ git cat-file -p \
|
$ git cat-file -p 2c4e4782bcb6b13a0e11b6961004dec8745e9d35
|
||||||
2c4e4782bcb6b13a0e11b6961004dec8745e9d35
|
040000 tree bcd2824258ddf007dae7f88da7d727fb3894691b Astro
|
||||||
040000 tree bcd2824258ddf007dae7f88da7d727fb3894691b
|
100644 blob 94aea57573b92d9188a3df4cf748b60efd968803 MyHelloWorldBean.java
|
||||||
Astro
|
100644 blob c55118d1afb2be6a6d0f728814c084d54e97db14 MyHelloWorldServlet.java
|
||||||
100644 blob 94aea57573b92d9188a3df4cf748b60efd968803
|
|
||||||
MyHelloWorldBean.java
|
|
||||||
100644 blob c55118d1afb2be6a6d0f728814c084d54e97db14
|
|
||||||
MyHelloWorldServlet.java
|
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
** Git Objects -- commits
|
** Git Objects -- commits 1/2
|
||||||
*** Commit
|
|
||||||
Information on a commit event:
|
Information on a commit event:
|
||||||
- The SHA1 of the top-level tree of the project.
|
- The SHA1 of the top-level tree of the project.
|
||||||
- The parent commit (or commits, if this commit is the result of
|
- The parent commit (or commits, if this commit is the result of a
|
||||||
a merge)
|
merge)
|
||||||
- The details of the author of the code that is being applied
|
- The details of the author of the code that is being applied with
|
||||||
with the commit (including date and time)
|
the commit (including date and time)
|
||||||
- The details of the person who applied the commit (including date and time)
|
- The details of the person who applied the commit (including date and time)
|
||||||
- The commit gpg signature, if present
|
- The commit gpg signature, if present
|
||||||
- The commit comment
|
- The commit comment
|
||||||
** Git Objects -- commits
|
** Git Objects -- commits 2/2
|
||||||
*** Commit
|
|
||||||
#+BEGIN_SRC shell
|
#+BEGIN_SRC shell
|
||||||
$ git cat-file -p \
|
$ git cat-file -p 37c5611a177c9eafbd17e4302b6d644434b1042b
|
||||||
37c5611a177c9eafbd17e4302b6d644434b1042b
|
|
||||||
tree 40b6262f3f3f5fc8cb8a0c78ca558a683dfc2323
|
tree 40b6262f3f3f5fc8cb8a0c78ca558a683dfc2323
|
||||||
parent 42608808a973b8e0c4a4b0105c2317d81b12851f
|
parent 42608808a973b8e0c4a4b0105c2317d81b12851f
|
||||||
parent 36d56f097ca81f06d77f46cbde3fc10cbf6639f9
|
parent 36d56f097ca81f06d77f46cbde3fc10cbf6639f9
|
||||||
author Master O'Theuniverse \
|
author Master O'Theuniverse <master.otheuniverse@example.com> 1529840879 +0100
|
||||||
<master.otheuniverse@example.com> \
|
committer Master O'Theuniverse <master.otheuniverse@example.com> 1529840879 +0100
|
||||||
1529840879 +0100
|
|
||||||
committer Master O'Theuniverse \
|
|
||||||
<master.otheuniverse@example.com> \
|
|
||||||
1529840879 +0100
|
|
||||||
|
|
||||||
REV18_5 now live
|
REV18_5 now live
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
** Git Objects -- tags
|
** Git Objects -- tags 1/2
|
||||||
*** Tag
|
|
||||||
A tag points to a commit object, and an annotated tag contains
|
A tag points to a commit object, and an annotated tag contains
|
||||||
additional information
|
additional information
|
||||||
- What object it's pointing at and its type
|
- What object it's pointing at and its type
|
||||||
- The name of the tag
|
- The name of the tag
|
||||||
- Who applied the tag (including date and time)
|
- Who applied the tag (including date and time)
|
||||||
- A tag comment
|
- A tag comment
|
||||||
** Git Objects -- tags
|
** Git Objects -- tags 2/2
|
||||||
*** Tag
|
|
||||||
#+BEGIN_SRC shell
|
#+BEGIN_SRC shell
|
||||||
$ git cat-file -p \
|
$ git cat-file -p 88a4c18867ccb1d7c398f285460d8abab3964e75
|
||||||
88a4c18867ccb1d7c398f285460d8abab3964e75
|
|
||||||
object 66d8336c2770d0d1cea3dcb0175611edb5e69f69
|
object 66d8336c2770d0d1cea3dcb0175611edb5e69f69
|
||||||
type commit
|
type commit
|
||||||
tag Rel1.0.a
|
tag Rel1.0.a
|
||||||
tagger Éibhear Ó hAnluain \
|
tagger Éibhear Ó hAnluain <eibhear.geo@gmail.com> 1529847749 +0100
|
||||||
<eibhear.geo@gmail.com> \
|
|
||||||
1529847749 +0100
|
|
||||||
|
|
||||||
An annotated tag for the Rel1 release
|
An annotated tag for the Rel1 release
|
||||||
|
|
||||||
$ git cat-file -t \
|
$ git cat-file -t 66d8336c2770d0d1cea3dcb0175611edb5e69f69
|
||||||
66d8336c2770d0d1cea3dcb0175611edb5e69f69
|
|
||||||
commit
|
commit
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
** "Content Addressable Filesystem"
|
** "Content Addressable Filesystem"
|
||||||
*** "Content Addressable Filesystem"
|
|
||||||
As the IDs of objects are based on their contents, they are
|
As the IDs of objects are based on their contents, they are
|
||||||
located in the git database according to that name
|
located in the git database according to that name
|
||||||
#+BEGIN_SRC shell
|
#+BEGIN_SRC shell
|
||||||
git rev-list --all --objects
|
git rev-list --all --objects
|
||||||
git cat-file -p \
|
git cat-file -p b5aea839bc89a0c7931af469ff9c145be18854d7
|
||||||
b5aea839bc89a0c7931af469ff9c145be18854d7
|
git cat-file -p b5aea839bc89a0c7931af469ff9c145be18854d7 | \
|
||||||
git cat-file -p \
|
|
||||||
b5aea839bc89a0c7931af469ff9c145be18854d7 | \
|
|
||||||
git hash-object --stdin
|
git hash-object --stdin
|
||||||
ls -l .git/objects/b5/aea839bc89a0c7931af469ff9c145be18854d7
|
ls -l .git/objects/b5/aea839bc89a0c7931af469ff9c145be18854d7
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
* The Deep trenches
|
* The Deep trenches -- Exotic creatures
|
||||||
**
|
|
||||||
*** Exotic creatures :B_block:BMCOL:
|
|
||||||
:PROPERTIES:
|
|
||||||
:BEAMER_col: 0.7
|
|
||||||
:BEAMER_env: block
|
|
||||||
:END:
|
|
||||||
file:./images/Alvinella_pompejana01.jpg
|
|
||||||
|
|
||||||
#+latex: {\tiny
|
#+CAPTION: By National Science Foundation (University of Delaware College of Marine Studies) - http://www.nsf.gov/od/lpa/news/press/01/pr0190.htm, Public Domain, https://commons.wikimedia.org/w/index.php?curid=7123122
|
||||||
By National Science Foundation (University of Delaware College of Marine Studies) - http://www.nsf.gov/od/lpa/news/press/01/pr0190.htm, Public Domain, https://commons.wikimedia.org/w/index.php?curid=7123122
|
#+ATTR_HTML: :width 60%
|
||||||
#+latex: }
|
file:./images/Alvinella_pompejana01.jpg
|
||||||
** The reflog
|
** The reflog
|
||||||
*** The reflog
|
|
||||||
- A log of all the changes to HEAD
|
- A log of all the changes to HEAD
|
||||||
- Local only: not involved in pulls, pushes or fetches.
|
- Local only: not involved in pulls, pushes or fetches.
|
||||||
- Useful for recovering accidentally removed commits
|
- Useful for recovering accidentally removed commits
|
||||||
- Completely clear the reflog
|
- Completely clear the reflog
|
||||||
: git reflog expire --expire=now \
|
#+BEGIN_SRC shell
|
||||||
: --expire-unreachable=now --verbose --all
|
git reflog expire --expire=now --expire-unreachable=now \
|
||||||
|
--verbose --all
|
||||||
|
#+END_SRC
|
||||||
** fsck and gc
|
** fsck and gc
|
||||||
*** fsck and gc
|
|
||||||
- fsck :: Analyse connectivity of the objects in the git
|
- fsck :: Analyse connectivity of the objects in the git
|
||||||
database. Useful for finding objects that aren't of any
|
database. Useful for finding objects that aren't of any use any
|
||||||
use any more.
|
more.
|
||||||
- gc :: "Garbage collector". Compress and pack objects, remove
|
- gc :: "Garbage collector". Compress and pack objects, remove
|
||||||
"danlging" and unreachable objects
|
"danlging" and unreachable objects
|
||||||
** Useful commands
|
** Useful commands
|
||||||
*** Useful commands
|
|
||||||
- Find the largest object in your git database
|
- Find the largest object in your git database
|
||||||
#+BEGIN_SRC shell
|
#+BEGIN_SRC shell
|
||||||
git cat-file \
|
git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize)' \
|
||||||
--batch-check='%(objecttype) %(objectname) %(objectsize)' \
|
--batch-all-objects | sed -n 's/^blob //p' | sort -n --key=2
|
||||||
--batch-all-objects | sed -n 's/^blob //p' | \
|
|
||||||
sort -n --key=2
|
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
- List all objects in your git database
|
- List all objects in your git database
|
||||||
: git rev-list --all --objects
|
#+BEGIN_SRC shell
|
||||||
|
git rev-list --all --objects
|
||||||
|
#+END_SRC
|
||||||
- Determine the filename related to a blob object
|
- Determine the filename related to a blob object
|
||||||
: git rev-list --objects --all | grep <objectID>
|
#+BEGIN_SRC shell
|
||||||
|
git rev-list --objects --all | grep <objectID>
|
||||||
|
#+END_SRC
|
||||||
- Determine commits that reference that file
|
- Determine commits that reference that file
|
||||||
: git log --follow -- "<fileNameAndPath>"
|
#+BEGIN_SRC shell
|
||||||
** Permanently removing a file from your git db
|
git log --follow -- "<fileNameAndPath>"
|
||||||
*** Permanently removing a file from your git db
|
#+END_SRC
|
||||||
|
** Permanently removing a file from your git db 1/2
|
||||||
- e.g. contains password information, v. large file not required, etc.
|
- e.g. contains password information, v. large file not required, etc.
|
||||||
- For each branch...
|
- For each branch...
|
||||||
+ Check it out
|
+ Check it out
|
||||||
: git checkout <branch>
|
#+BEGIN_SRC shell
|
||||||
|
git checkout <branch>
|
||||||
|
#+END_SRC
|
||||||
+ Remove the file from all commits
|
+ Remove the file from all commits
|
||||||
#+BEGIN_SRC shell
|
#+BEGIN_SRC shell
|
||||||
git filter-branch --tree-filter \
|
git filter-branch --tree-filter \
|
||||||
'rm -f <filePathAndName>' \
|
'rm -f <filePathAndName>' --prune-empty HEAD
|
||||||
--prune-empty HEAD
|
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
+ Clean up the original refs
|
+ Clean up the original refs
|
||||||
#+BEGIN_SRC shell
|
#+BEGIN_SRC shell
|
||||||
git for-each-ref --format="%(refname)" \
|
git for-each-ref --format="%(refname)" refs/original/ | \
|
||||||
refs/original/ | \
|
|
||||||
xargs -n 1 git update-ref -d
|
xargs -n 1 git update-ref -d
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
** Permanently removing a file from your git db
|
** Permanently removing a file from your git db 2/2
|
||||||
*** Permanently removing a file from your git db
|
|
||||||
- ... then ...
|
- ... then ...
|
||||||
- Clear out the reflog
|
- Clear out the reflog
|
||||||
: git reflog expire --expire-unreachable=now --all
|
#+BEGIN_SRC shell
|
||||||
The reflog maintains references to commits and objects you
|
git reflog expire --expire-unreachable=now --all
|
||||||
may want to remove.
|
#+END_SRC
|
||||||
|
The reflog maintains references to commits and objects you may
|
||||||
|
want to remove.
|
||||||
- Collect the garbage, regardless of age
|
- Collect the garbage, regardless of age
|
||||||
: git gc --prune=now
|
#+BEGIN_SRC shell
|
||||||
|
git gc --prune=now
|
||||||
|
#+END_SRC
|
||||||
- Sanity-check all objects
|
- Sanity-check all objects
|
||||||
: git fsck --unreachable --no-reflogs
|
#+BEGIN_SRC shell
|
||||||
|
git fsck --unreachable --no-reflogs
|
||||||
|
#+END_SRC
|
||||||
** Other interesting concepts
|
** Other interesting concepts
|
||||||
*** Other interesting concepts
|
- Porcelain vs Plumbing :: The commands that we use vs the
|
||||||
- *Porcelain vs Plumbing*: The commands that we use vs the commands that *they* use.
|
commands that *they* use.
|
||||||
+ *Porcelain*: =init=, =clone=, =fetch=, =push=, =add=, =commit=, etc.
|
+ Porcelain :: =init=, =clone=, =fetch=, =push=, =add=,
|
||||||
+ *Plumbing*: =hash-object=, =cat-file=, =write-tree=, =count-objects=, etc.
|
=commit=, etc.
|
||||||
- *submodules*: to link a separate git repository into yours
|
+ Plumbing :: =hash-object=, =cat-file=, =write-tree=,
|
||||||
- *fast-import*: to import data into a git repository from other,
|
=count-objects=, etc.
|
||||||
|
- submodules :: to link a separate git repository into yours
|
||||||
|
- fast-import :: to import data into a git repository from other,
|
||||||
non-git sources (e.g. cvs, subversion, etc.)
|
non-git sources (e.g. cvs, subversion, etc.)
|
||||||
** Resources
|
** Resources
|
||||||
*** Resources
|
|
||||||
- The git book :: https://git-scm.com/book/en/v2/
|
- The git book :: https://git-scm.com/book/en/v2/
|
||||||
- The git manual ::
|
- The git manual ::
|
||||||
#+BEGIN_SRC shell
|
#+BEGIN_SRC shell
|
||||||
|
|
|
@ -16,7 +16,6 @@ section {
|
||||||
|
|
||||||
pre,
|
pre,
|
||||||
code {
|
code {
|
||||||
font-size: 80%;
|
|
||||||
color: #000000;
|
color: #000000;
|
||||||
background-color: #e0e0e0;
|
background-color: #e0e0e0;
|
||||||
border-style: solid;
|
border-style: solid;
|
||||||
|
@ -24,11 +23,13 @@ code {
|
||||||
border-color: #c0c0c0;
|
border-color: #c0c0c0;
|
||||||
}
|
}
|
||||||
|
|
||||||
pre {
|
.org-src-container > pre {
|
||||||
padding: 0.5em;
|
padding: 0.5em;
|
||||||
|
font-size: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
code {
|
code {
|
||||||
|
font-size: 80%;
|
||||||
padding-right: 1px;
|
padding-right: 1px;
|
||||||
padding-left: 1px;
|
padding-left: 1px;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue