Add new git tips
This commit is contained in:
19
code/shell/commands/export_git_commits.sh
Normal file
19
code/shell/commands/export_git_commits.sh
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
if [[ $# -ne 1 ]]; then
|
||||||
|
echo "Usage: $0 <repo_path>"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
REPO_PATH="${1}"
|
||||||
|
PATCHES_PATH="$(mktemp -d)"
|
||||||
|
|
||||||
|
read -r -p 'Select your first commit to export'
|
||||||
|
FIRST_COMMIT_LINE=$(git -C "${REPO_PATH}" log --pretty=format:'%h: %cn <%ce>, %ah %ar, %s' | fzf)
|
||||||
|
read -r -p 'Select your last commit to export'
|
||||||
|
LAST_COMMIT_LINE=$(git -C "${REPO_PATH}" log --pretty=format:'%h: %cn <%ce>, %ah %ar, %s' | fzf)
|
||||||
|
|
||||||
|
FIRST_COMMIT_HASH=$(echo "${FIRST_COMMIT_LINE}" | cut -d':' -f1)
|
||||||
|
LAST_COMMIT_HASH=$(echo "${LAST_COMMIT_LINE}" | cut -d':' -f1)
|
||||||
|
|
||||||
|
git -C "${REPO_PATH}" format-patch --output-directory "${PATCHES_PATH}" "${LAST_COMMIT_HASH}~..${FIRST_COMMIT_HASH}"
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
# Git
|
# Git
|
||||||
|
|
||||||
## Exécuter git depuis un autre répertoire que celui du dépôt
|
## Exécuter git depuis un autre répertoire que celui du dépôt:
|
||||||
|
|
||||||
```
|
```
|
||||||
git -C <chemin_du_dépot> <commande_git>
|
git -C <chemin_du_dépot> <commande_git>
|
||||||
@@ -21,3 +21,22 @@ git config --global user.name ben
|
|||||||
git config --global user.email ben@nospam.org
|
git config --global user.email ben@nospam.org
|
||||||
git config --global core.editor vim
|
git config --global core.editor vim
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Copier un commit d'un dépôt à un autre:
|
||||||
|
|
||||||
|
```
|
||||||
|
cd repo_origin
|
||||||
|
git format-patch --output-directory "/home/user/git-patches" <commit_hash>
|
||||||
|
cd repo_dest
|
||||||
|
git am /home/user/git-patches/0001-xxxxxx.patch
|
||||||
|
```
|
||||||
|
|
||||||
|
## Exporter des commits de manière interactive:
|
||||||
|
|
||||||
|
[[!inline pages="code/shell/commands/export_git_commits.sh" rss="no" atom="no" feeds="no"]]
|
||||||
|
|
||||||
|
## Modifier les derniers commits:
|
||||||
|
|
||||||
|
```
|
||||||
|
git rebase -i HEAD~4
|
||||||
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user