User Tools

Site Tools


quickref:git

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
quickref:git [2013/08/20 07:37]
andy [Interactive Rebase]
quickref:git [2013/09/06 09:24]
andy
Line 8: Line 8:
  
 If you're not already moderately familiar with Git, strongly consider browsing the [[#Git Structure]] section first as it can make Git operations easier to understand. If you're not already moderately familiar with Git, strongly consider browsing the [[#Git Structure]] section first as it can make Git operations easier to understand.
 +
 +If you're just looking for some handy commands, check out the [[#​Recipes]] section.
  
  
Line 1178: Line 1180:
 </​graphviz>​ </​graphviz>​
  
-As can be seen, the source branch is intact and could be left in existence as required, but unlike a rebase its commits haven'​t become part of the history of the destination branch so future merges may well produce conflicts. It's also worth noting that, unlike a standard merge, the final commits ​on the branch do //not// become parents of the mainline commit. The merged commit could have equally been created by manually applying the diffs of each source commit and an entirely new commit created.+As can be seen, the source branch is intact and could be left in existence as required, but unlike a rebase its commits haven'​t become part of the history of the destination branch so future merges may well produce conflicts. It's also worth noting that, unlike a standard merge, the final commit(s) ​on the branch(es) do //not// become parents of the mainline commit. The merged commit could have equally been created by manually applying the diffs of each source commit and an entirely new commit created.
  
 ===== Remote Repositories ===== ===== Remote Repositories =====
Line 1303: Line 1305:
  
 The ''<​local branch>''​ here is typically a local branch name, but could be any commit specification (e.g. a SHA1 hash). The ''<​remote branch>''​ must be a real branch, however, to avoid creation of a **detached head**, but if a non-existent branch is specified then it will be created based on the source branch. The ''<​local branch>''​ here is typically a local branch name, but could be any commit specification (e.g. a SHA1 hash). The ''<​remote branch>''​ must be a real branch, however, to avoid creation of a **detached head**, but if a non-existent branch is specified then it will be created based on the source branch.
 +
 +<note important>​It'​s worth noting that this point that you should avoid modifying changes (for example, via an interactive rebase) once they'​ve been pushed or pulled to another repository unless you maintain both and are prepared to deal with the resultant conflicts.</​note>​
  
 Normally the push operation fails if the remote merge operation is anything other than a **fast-forward** (i.e. the local repository has already merged all of the remote changes). If this is not the case, it will exit with an appropriate error and the remote changes will need to be merged locally first. If the branch specification is prefixed with ''​+'',​ the update will be done even if the merge is not a fast-forward. Normally the push operation fails if the remote merge operation is anything other than a **fast-forward** (i.e. the local repository has already merged all of the remote changes). If this is not the case, it will exit with an appropriate error and the remote changes will need to be merged locally first. If the branch specification is prefixed with ''​+'',​ the update will be done even if the merge is not a fast-forward.
Line 2091: Line 2095:
 </​file>​ </​file>​
  
 +===== Recipes =====
  
 +The following are some handy pre-canned commands for specific situations. You can set up [[https://​git.wiki.kernel.org/​index.php/​Aliases|aliases]] for these as well.
 +
 +==== Log ====
 +
 +Show recent commits with relative dates and authors:
 +
 +<​code>​
 +git log --pretty=format:"​%C(yellow)%h %C(cyan)%ad%C(yellow)%C(bold)%d %Creset%s%Cgreen [%cn]"​\
 +        --decorate --date=relative
 +</​code>​
 +
 +Show the history of a specified file:
 +
 +<​code>​
 +git log -u -- <​filename>​
 +</​code>​
 +
 +Show the state of all branches and how they relate:
 +
 +<​code>​
 +git log --all --graph --oneline --decorate --simplify-by-decoration
 +</​code>​
quickref/git.txt ยท Last modified: 2015/07/02 11:36 by andy