malys
4/25/2014 - 7:53 AM

GIT Command GIT

GIT Command GIT

# https://rtyley.github.io/bfg-repo-cleaner/

git clone --mirror git://example.com/some-big-repo.git
# This is a bare repo, which means your normal files won't be visible, but it is a full copy of the Git database of your repository, and at this point you should make a backup of it to ensure you don't lose anything.
#Now you can run the BFG to clean your repository up:

java -jar bfg.jar --strip-blobs-bigger-than 100M some-big-repo.git
#The BFG will update your commits and all branches and tags so they are clean, but it doesn't physically delete the unwanted stuff. Examine the repo to make sure your history has been updated, and then use the standard git gc command to strip out the unwanted dirty data, which Git will now recognise as surplus to requirements:

cd some-big-repo.git
git reflog expire --expire=now --all && git gc --prune=now --aggressive
#
Finally, once you're happy with the updated state of your repo, push it back up (note that because your clone command used the --mirror flag, this push will update all refs on your remote server):

git push
#SSL ignore
set GIT_SSL_NO_VERIFY=true

##LOG
# Difference de commit entre deux branch
git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative master..branch-X
git log --graph --pretty=format:"%Cred%h%Creset - %C(cyan)%an%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset" --abbrev-commit --date=relative  --since="2 day ago"

##RESET
#Annule les commits après H-2 
git reset --hard HEAD@{2}

# to undo a git push
git push -f origin HEAD^:master
git push -f origin HEAD~3:master

# to get to previous commit (preserves working tree)
git reset --soft HEAD

# to get back to previous commit (you'll lose working tree)
git reset --hard HEAD^

## CHECKOUT
#Remove Remote branch
git branch -rd origin/xxxxx
git push origin :xxxxx


# revert local change
git checkout --

##TAG
#Rename tag http://stackoverflow.com/questions/1028649/how-do-you-rename-a-git-tag
git tag -l
git tag new old
git tag -d old
git push origin :refs/tags/old
git push --tags

#Create branch without commit change
git checkout -b new_branch_name

##STASH
rem https://stackoverflow.com/questions/11269256/how-to-name-a-stash-in-git
rem stash^{/<regex>}
rem :/<regex>
rem For example, when saving your stash with a save name:
git stash save "guacamole sauce WIP"

rem ... you can use a regular expression to address that stash:
git stash apply stash^{/guacamo}

##SUBMODULE
#recursive
git submodule --quiet foreach "ncu -p -e 1 -u frontfusion || :"

##REBASE
git config --global rerere.enabled true

## History
https://help.github.com/articles/remove-sensitive-data/