git rebase master
git rebase -i master
pick 1 Start my branch1
pick 2 Continue my branch1
git reflog### Output
0f8dde4 HEAD@{0}: rebase -i (finish): returning to refs/heads/master
0f8dde4 HEAD@{1}: rebase -i (squash): first + third
606813c HEAD@{2}: rebase -i (start): checkout f07ec95
b8fed7c HEAD@{3}: commit: third
e3025b3 HEAD@{4}: commit: second
606813c HEAD@{5}: commit: first
f07ec95 HEAD@{6}: commit (initial): initialgit checkout mastergit tag "Add-great-lib" 1git cherry-pick 1git checkout --detach Cgit cherry-pick Add-great-libgit checkout mastergit reset --hard HEAD~1git reflog
# reflog output...
# Find the commit xxx to which we want to reset
git reset xxxsource: https://www.sourcetreeapp.com/
source: https://www.gitkraken.com/git-client
Source: https://www.atlassian.com/blog/git/git-tig
COMMIT_EDITMSG
Last commit message.
config
Override git config for this repository.
description
Description of git repository, used by Gitweb.
FETCH_HEAD
Result of latest git fetch.
HEAD
The "you are here" of git, always linked to a git reference.
index
"staging area" content.
ORIG_HEAD
Updated while a merge or rebase is in progress.
Hash of the parent commit for the next operation.
packed-refs
Update by git garbage collection.
Stored the "sleeping" refs. (see here)
MERGE_HEAD
MERGE_MODE
Files used in merge. They are created at merge start and deleted once merge is over.
MERGE_MSG
Hash of last commit of this branch
Flag used to know which branch to merge when using git pull
ae4cc3ca... branch 'develop' of xxxx
face39bb... not-for-merge branch 'bugfix/fix-display-of-no-data-component' of xxxxBranch name on remote and address of remote.
hooks
User scripts run when specific event (before-commit, fetch...) are recognized.
info
Additional information for this repository.
Contains an exclude file which acts as a non shared local .gitignore
logs
git logbook, used by git reflog
objects
git core database (see git-cat-file)
rebase-apply
Working space used by git while running git rebase and git-am.
refs
references (branches, tags, stashes) most often accessed in this repository.
Can be automatically archived in packed-refs file.
[alias]
co = checkout
st = status --short --branch
mr = !sh -c 'git fetch $1 merge-requests/$2/head:mr-$1-$2 && git checkout mr-$1-$2' -
out = log @{u}..
in = log ..@{u}....
- repo: https://github.com/PyCQA/isort
rev: 5.10.1
hooks:
- id: isort
language_version: python3
args: ['--profile', 'black']Pros:
#!/bin/zsh
c=$(git branch | grep -c "$1")
if [[ "$c" -eq 1 ]]; then
git checkout $(git branch | grep "$1")
else
echo "'$1' is ambigus"
git branch | grep "$1"
exit 1
fi(icclim) icclim % cat .git/info/exclude
# git ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~
*-abel-*
*.ncUseful to exclude files such as:
Or any files related to the project but which should never be committed and shared.
Large files should not be committed as is within source code repository:
Solution: git Large File Storage (LFS)
Git Large File Storage (LFS) replaces large files such as audio samples, videos, datasets, and graphics with text pointers inside Git, while storing the file contents on a remote server like GitHub.com or GitHub Enterprise.
reference: https://git-lfs.github.com/
Cons of git (LFS)
Files
Message
Pull requests are really good, use them
Once all conflicts are solved run all test and make sure everything work.
For example, if a refactoring deletes a file which is not modified but used by a merged feature, git will not be able to see the issue of deleting this file.
Branching models
Gitflow
Branching models
Githubflow
Branching models
merge vs rebase
Don't
Branching models
merge vs rebase
Do
Branching models
merge vs rebase
A commit from Michel ?
commit 8684d0560cb7c51234cbefebd83409e90cb7e29f
Author: Michel michel.xxxx@viseo.com
Date: Wed Dec 6 12:40:14 2017 +0100
"Init presentation"
sha1(
commit_message,
commiter,
commit_date,
author,
authoring_date,
Hash-Of-Entire-Working-Directory
) .
│ main.java
│
├───.git
└───resources
│ logo.png
└───components
...
sha1(
"Init presentation",
"michel.xxxx@viseo.com",
Wed Dec 6 12:40:14 2017 +0100,
"michel.xxxx@viseo.com",
Wed Dec 6 12:40:14 2017 +0100,
aa1b2fb696a831c89c53f787e03d863691d2b671
)sha1(
meta data
commit_message
commiter
commit_date
author
authoring_date
Hash-Of-Entire-Working-Directory
hash-of-parent-commit
)git cherry-pick cool-feature~3..cool-featuregit config --global rerere.enabled truegit worktree add ../myproject_2nd_wt