Skip to content

Commit be7db89

Browse files
committed
Intermediate Git guidelines.
1 parent e6b2cc4 commit be7db89

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

README.org

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,8 @@ git status
266266
git log
267267
git log --oneline
268268
git log --oneline --graph
269+
git log --author=~Darren
270+
git log --since=5.days # or weeks, months, years
269271
#+END_SRC
270272
- You can identify commit by unique ID or by HEAD offset
271273
- HEAD is a pointer to the most recent commit
@@ -521,6 +523,15 @@ git pull origin master
521523
#+END_SRC
522524

523525
*** Edit conflict, stage, commit, and push
526+
Edit the file to resolve the conflict. You can delete one of the two lines, combine them, or make any other changes. Delete the conflict markers before staging the file (the lines beginning in "<", "=", and ">").
527+
#+BEGIN_EXAMPLE
528+
<<<<<<< HEAD
529+
This line added to separate "planets-clone" repo
530+
=======
531+
This line added to original "planets" repo
532+
>>>>>>> dabb4c8c450e8475aee9b14b4383acc99f42af1d
533+
#+END_EXAMPLE
534+
524535
You may want to enable a default merge tool:
525536
#+BEGIN_SRC bash
526537
git config --global merge.tool meld
@@ -531,6 +542,21 @@ git config --global merge.tool meld
531542
** Version control with source vs. notebooks
532543
- .ipynb files contain a lot of JSON boilerplate that isn't code
533544

545+
** Next steps (intermediate Git)
546+
*** Useful commands that you should add to you repertoire
547+
- git blame: See who changed each line of a file
548+
- git bisect: Find out when a change was introduced (good man page)
549+
- git revert: Undo your recent commits (good man page)
550+
- git add --patch: Stage a part of a file ("hunk") instead the entire file
551+
- git -i <command>: Run a command interactively, confirming each step
552+
*** Potentially dangerous commands that are useful in certain circumstances. Use with caution!
553+
- git reset: Throw away uncommitted changes (there are many options that affect what gets thrown away; read the documentation)
554+
- git reset --hard: Throw away some of your commits to get back to an earlier project state. Cannot be undone!
555+
- git rebase: Rewrite the history of branch A to include branch B. This is different than merging branch B into branch A; merging retains your project history, whereas rebasing rewrites that history.
556+
- git squash: Convert multiple commits into a single commit. This also rewrites your project history.
557+
*** Dangerous commands you should avoid
558+
- git cherry-pick: Copy a single commit from a different branch. This rewrites your project history piecemeal, which can make it difficult to merge branches in the future.
559+
534560
* Additional reading
535561
- The Pro Git book: https://git-scm.com/book/en/v2
536562
- "Git is built on a graph. Almost every Git command manipulates this graph. To understand Git deeply, focus on the properties of this graph, not workflows or commands.": https://codewords.recurse.com/issues/two/git-from-the-inside-out

0 commit comments

Comments
 (0)