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
#!/usr/bin/env bash workDir=$(mktemp --tmpdir -d tempDir_XXXXXXXX) zerosFile="$workDir/zeros" otherFile="$workDir/other" getDirSize() { directory=$1 message=$2 echo -en "\t==>\tDirectory size [$message] : " du -sh $1 } countOccurrencesInGitLog() { fullPathToFile=$1 trackedFile=$(basename "$1") echo -en "\t==>\tNUMBER OF OCCURRENCES OF '$trackedFile' IN 'git log' : " git log --name-status | grep -c "$trackedFile" } # init cd "$workDir" git init getDirSize "$workDir" 'Empty Git repository' # create and commit "$otherFile" echo 'this is an other file' > "$otherFile" git a "$otherFile" git co -m 'this is an other file' getDirSize "$workDir" "After creating + committing the 'other' file" # create and commit "$zerosFile" dd if=/dev/zero bs=1K count=100 of="$zerosFile" getDirSize "$workDir" "'zeros' file created but not committed yet" git a "$zerosFile" git co -m 'Lots of zeros !!! (initial commit)' getDirSize "$workDir" "'zeros' file committed" # append data to "$zerosFile" + commit for i in {1..5}; do echo "hello world ($i)" >> "$zerosFile" git a "$zerosFile" git co -m "hello world ($i)" getDirSize "$workDir" "After hello world ($i) in 'zeros' file" done # cleaning the git repo git gc getDirSize "$workDir" "After 'git gc' (1)" # untracking "$zerosFile" git rm --cached "$zerosFile" git co -m "rm --cached 'zeros'" getDirSize "$workDir" "After untracking the 'zeros' file + commit" # what about the git log (1) ? countOccurrencesInGitLog "$zerosFile" # cleaning the git repo git gc getDirSize "$workDir" "After 'git gc' (2)" # removing the 'zeros' file rm "$zerosFile" getDirSize "$workDir" "After 'rm' of 'zeros' file" # cleaning the git repo git gc getDirSize "$workDir" "After 'git gc' (3)" # what about the git log (2) ? countOccurrencesInGitLog "$zerosFile" # cleaning before leaving cd .. [ -d "$workDir" ] && rm -rf "$workDir"
Initialized empty Git repository in /tmp/tempDir_FWkkVbkH/.git/ ==> Directory size [Empty Git repository] : 35K /tmp/tempDir_FWkkVbkH [master (root-commit) 599b54f] this is an other file 1 file changed, 1 insertion(+) create mode 100644 other ==> Directory size [After creating + committing the 'other' file] : 50K /tmp/tempDir_FWkkVbkH 100+0 records in 100+0 records out 102400 bytes (102 kB, 100 KiB) copied, 0.000523495 s, 196 MB/s ==> Directory size ['zeros' file created but not committed yet] : 150K /tmp/tempDir_FWkkVbkH [master daa0106] Lots of zeros !!! (initial commit) 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 zeros ==> Directory size ['zeros' file committed] : 155K /tmp/tempDir_FWkkVbkH [master bc46b8c] hello world (1) 1 file changed, 0 insertions(+), 0 deletions(-) ==> Directory size [After hello world (1) in 'zeros' file] : 162K /tmp/tempDir_FWkkVbkH [master 8ceab4f] hello world (2) 1 file changed, 0 insertions(+), 0 deletions(-) ==> Directory size [After hello world (2) in 'zeros' file] : 168K /tmp/tempDir_FWkkVbkH [master d35a527] hello world (3) 1 file changed, 0 insertions(+), 0 deletions(-) ==> Directory size [After hello world (3) in 'zeros' file] : 174K /tmp/tempDir_FWkkVbkH [master 7db7977] hello world (4) 1 file changed, 0 insertions(+), 0 deletions(-) ==> Directory size [After hello world (4) in 'zeros' file] : 182K /tmp/tempDir_FWkkVbkH [master 6cd929a] hello world (5) 1 file changed, 0 insertions(+), 0 deletions(-) ==> Directory size [After hello world (5) in 'zeros' file] : 188K /tmp/tempDir_FWkkVbkH Counting objects: 21, done. Delta compression using up to 2 threads. Compressing objects: 100% (19/19), done. Writing objects: 100% (21/21), done. Total 21 (delta 6), reused 0 (delta 0) ==> Directory size [After 'git gc' (1)] : 153K /tmp/tempDir_FWkkVbkH rm 'zeros' [master d68e9bd] rm --cached 'zeros' 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 zeros ==> Directory size [After untracking the 'zeros' file + commit] : 156K /tmp/tempDir_FWkkVbkH ==> NUMBER OF OCCURRENCES OF 'zeros' IN 'git log' : 9 Counting objects: 22, done. Delta compression using up to 2 threads. Compressing objects: 100% (14/14), done. Writing objects: 100% (22/22), done. Total 22 (delta 6), reused 21 (delta 6) ==> Directory size [After 'git gc' (2)] : 154K /tmp/tempDir_FWkkVbkH ==> Directory size [After 'rm' of 'zeros' file] : 53K /tmp/tempDir_FWkkVbkH Counting objects: 22, done. Delta compression using up to 2 threads. Compressing objects: 100% (14/14), done. Writing objects: 100% (22/22), done. Total 22 (delta 6), reused 22 (delta 6) ==> Directory size [After 'git gc' (3)] : 53K /tmp/tempDir_FWkkVbkH ==> NUMBER OF OCCURRENCES OF 'zeros' IN 'git log' : 9
---------- 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.