From 4390a617a9da4ba2e0914d80f1d0ced6f821fed3 Mon Sep 17 00:00:00 2001 From: egrace479 Date: Tue, 19 Nov 2024 16:49:23 -0500 Subject: [PATCH 1/2] Add tip on renaming files tracked with git --- docs/wiki-guide/Command-Line-Cheat-Sheet.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/wiki-guide/Command-Line-Cheat-Sheet.md b/docs/wiki-guide/Command-Line-Cheat-Sheet.md index 757282b..ef83b2f 100644 --- a/docs/wiki-guide/Command-Line-Cheat-Sheet.md +++ b/docs/wiki-guide/Command-Line-Cheat-Sheet.md @@ -2,7 +2,7 @@ See also [GitHub's Markdown Guide](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax). -## Useful bash, emacs, and git: +## Useful bash and git | Command | Action | | --- | --- | | ` -h` | print the help documentation for a command, showing usage information and options | @@ -29,6 +29,9 @@ See also [GitHub's Markdown Guide](https://docs.github.com/en/get-started/writin | `git checkout ` | checkout branch | | `git branch -d ` | delete branch | +!!! tip "Pro tip: Simplify your git history" + - Use `git mv` to rename a file so that it is tracked as a rename (with or without changes). - If you rename a file then use `git add .` or similar, the diff will show the deletion of the original file and addition of a "completely new" file, even if nothing has changed. This makes reviewing changes much more complicated than necessary. + #### Usual Process After making changes to a file on a branch, check the status of your current working branch (with `git status`). Then, you "add" the file, state what is new about the file ("commit the change"), and `push` the file from your local copy of the repo to the remote copy: From 0d7ffe2b0712059420ab7e1284e85ee2b7ab863d Mon Sep 17 00:00:00 2001 From: egrace479 Date: Wed, 20 Nov 2024 13:13:27 -0500 Subject: [PATCH 2/2] Clarify suggestions to avoid unwanted file commits and unnecessary diffs --- docs/wiki-guide/Command-Line-Cheat-Sheet.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/wiki-guide/Command-Line-Cheat-Sheet.md b/docs/wiki-guide/Command-Line-Cheat-Sheet.md index ef83b2f..c43abb9 100644 --- a/docs/wiki-guide/Command-Line-Cheat-Sheet.md +++ b/docs/wiki-guide/Command-Line-Cheat-Sheet.md @@ -30,7 +30,8 @@ See also [GitHub's Markdown Guide](https://docs.github.com/en/get-started/writin | `git branch -d ` | delete branch | !!! tip "Pro tip: Simplify your git history" - - Use `git mv` to rename a file so that it is tracked as a rename (with or without changes). - If you rename a file then use `git add .` or similar, the diff will show the deletion of the original file and addition of a "completely new" file, even if nothing has changed. This makes reviewing changes much more complicated than necessary. + - Use `git mv` to rename a file so that it is tracked as a rename (with or without changes). + - If you rename a file then `git add` its parent directory, the diff will show the deletion of the original file and addition of a "completely new" file, even if nothing has changed. This makes reviewing changes much more complicated than necessary. #### Usual Process After making changes to a file on a branch, check the status of your current working branch (with `git status`). Then, you "add" the file, state what is new about the file ("commit the change"), and `push` the file from your local copy of the repo to the remote copy: @@ -44,6 +45,9 @@ git push ``` +!!! tip "Pro tip: Check the stage" + After using `git add ` or `git add ` (a pattern match), run `git status` to ensure that all intended files--and ***only*** intended files--are staged for commit. + !!! note Note If you need to update your branch with changes from the remote `main`, first switch to the branch, then set pull from `main` instead of the current branch, as below. ```bash