Skip to content

Instantly share code, notes, and snippets.

@Avgilles
Last active September 28, 2023 08:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Avgilles/65f68b9a8c1ba98b6744068161e9c84b to your computer and use it in GitHub Desktop.
Save Avgilles/65f68b9a8c1ba98b6744068161e9c84b to your computer and use it in GitHub Desktop.

VSCODE plugin : GIT GRAPH

Git command important

Visualisation

Historique git

git log

Afficher le log gît et avoir tout les hash pour chaque commit

Git log --oneline

reset commit (enlever historique)

Git reset --hard hash_commit

revert one file

git checkout HEAD -- /directory/my-file.txt

push

Git push -f

Create a branch and switch

git checkout -b <new-branch-name> # create a new branch
git switch <branch-name> # Switch branch

push to the new branch

git push --set-upstream origin <develop>

voir toute les branche

git branch -a

voir les historiques de la brancgh

git reflog

voir historique de tout le monde

git log --reflog

Changer de head

git reset --hard HEAD       (going back to HEAD)

git reset --hard HEAD^      (going back to the commit before HEAD)
git reset --hard HEAD~1     (equivalent to "^")

creates gitignore file

touch .gitignore

detruire fichier de maniere récursif et forcé

rm -rf UE_mocap.git/

Pour avoir le manuel

man rm

copie via ssh

scp -r dossierSource etudiants@193.54.159.122:/home/etudiants/21groupe2

stash

git stash save "Stash message for reference"  #To add changes to stash stack
git stash list					 		 	  #Shows all the stashed change list
git stash clear 							  #clears stash list
To apply the stash changes :
a) git stash apply stash @{n}
	you can reapply the changes to your working copy and keep them in your stash with git stash apply
b) git stash pop stash@{n} 
 -> Popping your stash removes the changes from your stash and reapplies them to your working copy
	n - stash number to be applied  		  #Applying stash changes
git stash -u     -u optiontells git stash to also stash your untracked files
git stash drop stash@{1}

Clean the history

git add . --all

git commit --fixup <id_hash>

git rebase -i --autosquash <id_hash_more_old>

git push --force origin <branch_to_push>

Lors du rebase le fixup va s'automatiquement se merger.

revert only one file

how to know the hash :

git rev-parse origin/master

revert the file

git checkout c5f567 -- file1/to/restore file2/to/restore

revert a directory

git checkout .\tdhoudini\hda\UNIT_import.hda\

squash repo

git rebase --interactive 7efe9dde16d79ea2c80aaa22a2e4c7e985ed65f8 --autosquash

git commit --fixup hash

reset to a commit

git reset --soft hash

Exemble choisir le commit en fonction du head

# N: number of comits to rebase
git rebase -i HEAD~N

Appliquer les dernieres modif a ma branche

git fetch origin master:master

Merge request command line

no fast forwad

git merge fixy_vdb_fur --no-ff

CI/CD

create Tag

git tag "1.8.0"
git push origin 1.8.0

delete locally:

git tag -d

delete remotely:

git push origin :refs/tags/

another way to delete remotely:

git push --delete origin

Stash

git stash
git stash apply

Rebase from master

git pull --rebase origin master

Pour recup le current HEAD (a tester)

git rev-parse --abbrev-ref HEAD

rename = "!f() { branch_name=$(git rev-parse --abbrev-ref HEAD); git branch -m $1; git push origin $1; git push origin --delete $branch_name; }; f"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment