add content to git file
This commit is contained in:
parent
d468dd1812
commit
5ed469ec78
40
IT/git.md
40
IT/git.md
@ -1,40 +0,0 @@
|
||||
# git
|
||||
|
||||
## delete a file only from git repository
|
||||
|
||||
`git rm -rf --cached`
|
||||
|
||||
## delete a file from complete history
|
||||
|
||||
be carefull can't push repo last time use
|
||||
|
||||
`git filter-branch --index-filter "git rm -rf --cached --ignore-unmatch logbook.md" HEAD`
|
||||
|
||||
## example de déclencheur git
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
GIT_REPO=`pwd`
|
||||
SITE_NAME=notebook
|
||||
TMP_GIT_CLONE="/tmp/$SITE_NAME"
|
||||
PUBLIC_WWW="/usr/share/nginx/html/$SITE_NAME"
|
||||
# get branch name
|
||||
if ! [ -t 0 ]; then
|
||||
read -a ref
|
||||
fi
|
||||
IFS='/' read -ra REF <<< "${ref[2]}"
|
||||
branch="${REF[2]}"
|
||||
|
||||
if [ "master" == "$branch" ]; then
|
||||
mkdir -p $TMP_GIT_CLONE
|
||||
echo "download repo"
|
||||
git clone --recursive $GIT_REPO $TMP_GIT_CLONE
|
||||
cd $TMP_GIT_CLONE
|
||||
export PATH="$HOME/.local/bin:$PATH"
|
||||
make install -e BUILDDIR=$PUBLIC_WWW
|
||||
echo "Cleaning up"
|
||||
rm -Rf $TMP_GIT_CLONE
|
||||
fi
|
||||
exit
|
||||
|
||||
```
|
47
IT/git/Rewrite_History.md
Normal file
47
IT/git/Rewrite_History.md
Normal file
@ -0,0 +1,47 @@
|
||||
# Rewrite Git History
|
||||
|
||||
## Changing the Last Commit
|
||||
|
||||
If you want to modify your last commit message:
|
||||
|
||||
`git commit --amend`
|
||||
|
||||
## Rewrite multiple Commit
|
||||
|
||||
for that you need to use rebase in interactive mode like this:
|
||||
|
||||
` git rebase -i HEAD^3 `
|
||||
|
||||
this will open an editor wit list of commit you need to modiy this with needed action to do
|
||||
|
||||
### Reordering Commit
|
||||
|
||||
ON this editor you can invert line to change commit order, git will reaply commit in wew order
|
||||
|
||||
### Squash & fixup commit
|
||||
|
||||
**Squash** option will merge will merge xommit with the previous and ad commit message in the new commit message
|
||||
|
||||
**Fixup** do same thing put forgot commit message
|
||||
|
||||
### Splitting a Commit
|
||||
|
||||
you can do that with **edit** command
|
||||
|
||||
git rebase will stop after apply commit where you hae put edit
|
||||
|
||||
ad this moment you can process to a Head reset and commit when you want to add commit modification like ewample below
|
||||
|
||||
```sh
|
||||
git reset HEAD^
|
||||
git add README
|
||||
git commit -m 'Update README formatting'
|
||||
git add lib/simplegit.rb
|
||||
git commit -m 'Add blame'
|
||||
git rebase --continue
|
||||
```
|
||||
|
||||
### delete
|
||||
|
||||
**drop** will delete comite rebase will not apply modification during processing
|
||||
to use by example if you have done a modifcation and a revert
|
66
IT/git/git.md
Normal file
66
IT/git/git.md
Normal file
@ -0,0 +1,66 @@
|
||||
# git
|
||||
|
||||
## Add in staging only a part of modification done in a file
|
||||
|
||||
`git add -p`
|
||||
|
||||
this will ask if you want to add each modification with this option:
|
||||
|
||||
- *y* - Yes, add this hunk
|
||||
- *n* - No, don’t add this hunk
|
||||
- *d* - No, don’t add this hunk and all other remaining hunks. Useful if you’ve already added what you want to, and want to skip over the rest
|
||||
- *s* - Split the hunk into smaller hunks. This only works if there’s unchanged lines between the changes in the displayed hunk, so this wouldn’t have any effect in the example above
|
||||
- *e* - Manually edit the hunk. This is probably the most powerful option. As promised, it will open the hunk in a text editor and you can edit it to your hearts content
|
||||
|
||||
## delete a file only from git repository
|
||||
|
||||
`git rm -rf --cached`
|
||||
|
||||
## delete a file from complete history
|
||||
|
||||
be carefull can't push repo last time use
|
||||
|
||||
`git filter-branch --tree-filter 'rm -f passwords.txt' HEAD`
|
||||
|
||||
## changing email adress
|
||||
|
||||
```
|
||||
$ git filter-branch --commit-filter '
|
||||
if [ "$GIT_AUTHOR_EMAIL" = "schacon@localhost" ];
|
||||
then
|
||||
GIT_AUTHOR_NAME="Scott Chacon";
|
||||
GIT_AUTHOR_EMAIL="schacon@example.com";
|
||||
git commit-tree "$@";
|
||||
else
|
||||
git commit-tree "$@";
|
||||
fi' HEAD
|
||||
```
|
||||
|
||||
## example de déclencheur git dans un dépot git
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
GIT_REPO=`pwd`
|
||||
SITE_NAME=notebook
|
||||
TMP_GIT_CLONE="/tmp/$SITE_NAME"
|
||||
PUBLIC_WWW="/usr/share/nginx/html/$SITE_NAME"
|
||||
# get branch name
|
||||
if ! [ -t 0 ]; then
|
||||
read -a ref
|
||||
fi
|
||||
IFS='/' read -ra REF <<< "${ref[2]}"
|
||||
branch="${REF[2]}"
|
||||
|
||||
if [ "master" == "$branch" ]; then
|
||||
mkdir -p $TMP_GIT_CLONE
|
||||
echo "download repo"
|
||||
git clone --recursive $GIT_REPO $TMP_GIT_CLONE
|
||||
cd $TMP_GIT_CLONE
|
||||
export PATH="$HOME/.local/bin:$PATH"
|
||||
make install -e BUILDDIR=$PUBLIC_WWW
|
||||
echo "Cleaning up"
|
||||
rm -Rf $TMP_GIT_CLONE
|
||||
fi
|
||||
exit
|
||||
|
||||
```
|
Loading…
Reference in New Issue
Block a user