Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tip on renaming files tracked with git #9

Merged
merged 2 commits into from
Nov 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion docs/wiki-guide/Command-Line-Cheat-Sheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
| --- | --- |
| `<cmd> -h` | print the help documentation for a command, showing usage information and options |
Expand All @@ -29,6 +29,10 @@ See also [GitHub's Markdown Guide](https://docs.github.com/en/get-started/writin
| `git checkout <branch>` | checkout branch |
| `git branch -d <branch>` | 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 `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:

Expand All @@ -41,6 +45,9 @@ git push

```

!!! tip "Pro tip: Check the stage"
After using `git add <folder>` or `git add <regex>` (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
Expand Down