workDir=$(mktemp --tmpdir -d testGit.XXXXXXXX); echo "$workDir"; cd "$workDir"; git init echo 'hello world' > file1; git add file1; git commit -m 'commit 1' git mv file1 file2; git commit -m 'rename' echo "Don't panic" >> file2; git add file2; git commit -m 'commit 2' git log file2 lists 'commit 2' + 'rename' commits git log --follow file2 lists all commits cd ..; [ -d "$workDir" ] && rm -rf "$workDir"
workDir=$(mktemp --tmpdir -d testGit.XXXXXXXX); echo "$workDir"; cd "$workDir"; git init echo 'hello world' > file1; git add file1; git commit -m 'commit 1' echo "Don't panic" >> file1; git mv file1 file2; git add file2; git commit -m 'commit 2' git log file2 lists 'commit 2' only git log --follow file2 lists all commits cd ..; [ -d "$workDir" ] && rm -rf "$workDir"
delete the deleted files.
deletedand can actually be retrieved from the Git history. The method below helps deflating the repository by actually deleting files, i.e. files affected by the commands below will be taken out of the history and will be gone forever.
deleted filesare still worth being saved in the history, it's up to you to chose wisely which ones to keep or remove, and not blindly use the whole list of deleted files.
=== Deleted paths by reverse accumulated size === git filter-repo did everything for us Format: unpacked size, packed size, date deleted, path name(s) 857646 618500 2018-06-04 bar/baz/foo.pdf 857646 618500 2018-06-04 foo/bar/foo/bar.pdf 857646 618500 2018-06-04 foo/bar/baz/foobar.pdf plenty of documentation Ideletedbecause it was obsolete 513453 444710 2016-11-16 bar/foo/baz.pdf 513453 444710 2016-11-16 foo/bar/foo/foofoo.pdf 376869 337648 2016-11-16 bar/foo/barfoo.pdf 376869 337648 2016-11-16 foo/bar/foo/bazbaz.pdf 1556701 327981 2016-11-15 bar/baz/bazfoo.eps 1556701 327981 2016-11-15 foo/bar/baz/barbar.eps 225216471 317154 2020-09-23 foo/foo.xml has a very long history of changes, but compresses well 296129 293152 2020-06-16 foo/bar/foobaz.odt (~3000 more lines)
weapons of mass deletion, here are some one-liners that may prove useful :
mightbe chained, you may not want to apply these on all lines of path-deleted-sizes.txt
A---B---C---D master \ X---Y---Z feature
A---B---C---D---Z' master \ X---Y---Z feature
A---B---C---D---Z' master \ X---Y---Z feature
A---B---C---D---Z' master \ X---Y featureLooks like Git detected that Z and Z' do the same changes, hence hides Z. How can I confirm ?
Note that any commits in HEAD which introduce the same textual changes as a commit in HEAD..upstream are omitted (i.e., a patch already accepted upstream with a different commit message or timestamp will be skipped).
At work, there's a shared Git repository where you can push any branch (mostly feature branches, actually) except the master branch. This is because the development team leaders / code quality specialists want to review every commit before accepting it on master. Thus, they make sure every commit meets the internal coding standards (and succeeds at the CI tests, of course).
So, when the development of your feature is done and you feel it's ready to join the master branch, you ask —via the web UI— your colleagues to merge your branch.
[credential]
helper = cache --timeout=3600
Host github.com User git not an example, this MUST be "git" IdentityFile /home/stuart/.ssh/github
---------- 1 kevin developers 12 Dec 23 11:37 /tmp/testGit/test.txt
[master (root-commit) e13e5bb] hello
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 test.txt
Committed with 644 permission whereas the file actually has 000.
-r-------- 1 kevin developers 12 Dec 23 11:37 /tmp/testGit/test.txt (no diff seen by Git)
-rw------- 1 kevin developers 12 Dec 23 11:37 /tmp/testGit/test.txt (no diff seen by Git)
-rwx------ 1 kevin developers 12 Dec 23 11:37 /tmp/testGit/test.txt diff --git a/test.txt b/test.txt old mode 100644 new mode 100755
[master 93560cf] u+x
0 files changed, 0 insertions(+), 0 deletions(-)
mode change 100644 => 100755 test.txt/
-rwxr----- 1 kevin developers 12 Dec 23 11:37 /tmp/testGit/test.txt (no diff seen by Git)
-rwxrw---- 1 kevin developers 12 Dec 23 11:37 /tmp/testGit/test.txt (no diff seen by Git)
-rwxrwx--- 1 kevin developers 12 Dec 23 11:37 /tmp/testGit/test.txt (no diff seen by Git)
-rwxrwxr-- 1 kevin developers 12 Dec 23 11:37 /tmp/testGit/test.txt (no diff seen by Git)
-rwxrwxrw- 1 kevin developers 12 Dec 23 11:37 /tmp/testGit/test.txt (no diff seen by Git)
-rwxrwxrwx 1 kevin developers 12 Dec 23 11:37 /tmp/testGit/test.txt (no diff seen by Git)
[master 891cf3b] Blah 1 files changed, 1 insertions(+), 0 deletions(-) create mode 100644 test2.txt
for person in u g o; do for permission in r w x; do echo $person+$permission chmod $person+$permission $myOtherFile ls -l $myOtherFile git diff $myOtherFile chmod $person-$permission $myOtherFile echo done done
u+r -r-------- 1 kevin developers 15 Dec 23 12:55 /tmp/testGit/test2.txt u+w --w------- 1 kevin developers 15 Dec 23 12:55 /tmp/testGit/test2.txt u+x ---x------ 1 kevin developers 15 Dec 23 12:55 /tmp/testGit/test2.txt diff --git a/test2.txt b/test2.txt old mode 100644 new mode 100755 g+r ----r----- 1 kevin developers 15 Dec 23 12:55 /tmp/testGit/test2.txt g+w -----w---- 1 kevin developers 15 Dec 23 12:55 /tmp/testGit/test2.txt g+x ------x--- 1 kevin developers 15 Dec 23 12:55 /tmp/testGit/test2.txt o+r -------r-- 1 kevin developers 15 Dec 23 12:55 /tmp/testGit/test2.txt o+w --------w- 1 kevin developers 15 Dec 23 12:55 /tmp/testGit/test2.txt o+x ---------x 1 kevin developers 15 Dec 23 12:55 /tmp/testGit/test2.txt
hook name | is run at | trigger |
---|---|---|
post-receive | a local repository | when the local repository is the destination of a git push |
GIT_DIR
variable. Suggested way of proceeding :
OLD_GIT_DIR=$GIT_DIR
unset GIT_DIR
(part of the script where taking actions on a repo occur)
GIT_DIR=$OLD_GIT_DIR
commit 93ce9bef143d57b6c0133d659db0c3030c24f75f
Author: Thomas ANDERSON <thomas.anderson@metacortex.com>
Date: Mon Dec 15 17:54:22 2014 +0100
Hello to people.
commit [length of commit metadata]NULL
author firstname lastname email
committer firstname lastname email
commit message
Only rewrite that part of history which you alone possess (source) : don't amend your last commit if you've already pushed it (source) !
It is also possible to proceed with git clone --bare.
Cloning into 'capifony'...
ssh: connect to host github.com port 22: Connection timed out
fatal: The remote end hung up unexpectedly
Cloning into 'capifony'...
fatal: unable to connect to github.com:
github.com[0: 204.232.175.90]: errno=Connexion terminée par expiration du délai d'attente
Cloning into 'ansiblefest'... fatal: unable to access 'https://github.com/ehashman/ansiblefest.git/': Failed to connect to 10.2.0.20 port 3128: Connection timed out
http_proxy=http://user:password@host:port
[http] proxy = http://user:password@host:port
HEAD
valuesHEAD@{2}
means where HEAD used to be two moves ago
master@{one.week.ago}
means where master used to point to one week ago in this local repository
centralor
serverrole more than any other. However, developers teams need some kind of
central pointto act as a reference for the whole team. This
central repositoryis called the upstream repository, it is typically the one developers interact with via GitLab.
tracking branch(and the branch it tracks is called an upstream branch). There are several ways to associate a local branch with a remote branch.