Difference between revisions of "HowToGit"

From Lost In Wonderlands
Jump to: navigation, search
(How-To)
Line 111: Line 111:
 
== How-To ==
 
== How-To ==
  
* how to get a file history
+
* how to get a file history
 
   git log -- <filePath>
 
   git log -- <filePath>
 
   git log <filepath>
 
   git log <filepath>
  
* using reflog and git reset to cancel actions
+
* using reflog and git reset to cancel actions
 
   
 
   
* resetting  
+
* resetting  
  
* cancelling the last pushed commit
+
* cancelling the last pushed commit
git revert
+
  git revert
  
* cancelling the last commit (not yet pushed)
+
* cancelling the last commit (not yet pushed)
git reset HEAD~
+
  git reset HEAD~
  
* resetting a local branch after the remote branch on the server
+
* resetting a local branch after the remote branch on the server
git reset --hard origin/<myRemoteBranch>
+
  git reset --hard origin/<myRemoteBranch>
  
* This removes everything from the index, then just run:
+
* This removes everything from the index, then just run:
git rm -r --cached .
+
  git rm -r --cached .
  
* Applying a .gitignore file added well after having committed file
+
* Applying a .gitignore file added well after having committed file
git rm -r --cached .
+
  git rm -r --cached .
git add .
+
  git add .
git commit -m ".gitignore is now working"
+
  git commit -m ".gitignore is now working"
  
  
* patches
+
* patches
**create a patch
+
**create a patch
git diff >> patch file
+
  git diff >> patch file
git format-patch patch-file
+
  git format-patch patch-file
  
 
  ** accept a patch
 
  ** accept a patch
 
   git apply patch_file
 
   git apply patch_file
  
** https://www.devroom.io/2009/10/26/how-to-create-and-apply-a-patch-with-git/
+
** https://www.devroom.io/2009/10/26/how-to-create-and-apply-a-patch-with-git/

Revision as of 18:56, 15 March 2019

How To Git

NeXT Steps

 here everything has yet to be done !

coming soon :


Everything You Always Wanted to Know on git [seldom]... (But Were Afraid to Ask) a collection of links of interest

See also


useful commands

gitk
gitk --all
git init 
git clone
git config --list
git log
git log --oneline
git log -- file
git log --oneline <filePath>


git status
git stash
git stash pop
git fetch
git pull
git pull --rebase
git branch
git branch -a 
git branch -r
git branch -D <branchname>
git branch -m newNameOfLocalBranch
git branch -m branchToRename newNameOfBranchToRename
git branch --set-upstream-to=origin/nomBranchRemote nomBranchLocale
git tag
git checkout
git checkout -b <branchname>
git cherry-pick <commit sha1>
git cherry-pick --abort
git merge
get rebase
git rebase -i
git rebase --interractive --onto 
git rerere can be activated and set to be used automatically by git rebase


git reflog
git reset
git diff
git difftool
git mergetool
git diff <filePath>
git difftool <filePath>


git add
git add -a
git add -p
git rm
git mv
git grep
git commit
git commit -m "commit message text"
git commit -p
git commit --amend
git push
git push origin nomBranche
git stash
git stash pop
git stash clear
git stash applymvnc
git reset --hard origin/<myRemoteBranch>
alias:
git config --global alias.newCommand 'Commande en entier sans le "git"'
   Exemple : git config --global alias.unstage 'reset HEAD --'
   Usefull ones :
   git config --global alias.st 'status'
   git config --global alias.co 'checkout'
   git config --global alias.cp 'cherry-pick'
git bisect

How-To

  • how to get a file history
 git log -- <filePath>
 git log <filepath>
  • using reflog and git reset to cancel actions
  • resetting
  • cancelling the last pushed commit
 git revert
  • cancelling the last commit (not yet pushed)
 git reset HEAD~
  • resetting a local branch after the remote branch on the server
 git reset --hard origin/<myRemoteBranch>
  • This removes everything from the index, then just run:
 git rm -r --cached .
  • Applying a .gitignore file added well after having committed file
 git rm -r --cached .
 git add .
 git commit -m ".gitignore is now working"


  • patches
    • create a patch
 git diff >> patch file
 git format-patch patch-file
** accept a patch
 git apply patch_file