Skip to content

Commit dc5d08c

Browse files
authored
Merge pull request #9 from Imageomics/update/cheat-sheet
Add tip on renaming files tracked with git
2 parents be8e0fc + 0d7ffe2 commit dc5d08c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

docs/wiki-guide/Command-Line-Cheat-Sheet.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
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).
44

5-
## Useful bash, emacs, and git:
5+
## Useful bash and git
66
| Command | Action |
77
| --- | --- |
88
| `<cmd> -h` | print the help documentation for a command, showing usage information and options |
@@ -29,6 +29,10 @@ See also [GitHub's Markdown Guide](https://docs.github.com/en/get-started/writin
2929
| `git checkout <branch>` | checkout branch |
3030
| `git branch -d <branch>` | delete branch |
3131

32+
!!! tip "Pro tip: Simplify your git history"
33+
- Use `git mv` to rename a file so that it is tracked as a rename (with or without changes).
34+
- 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.
35+
3236
#### Usual Process
3337
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:
3438

@@ -41,6 +45,9 @@ git push
4145

4246
```
4347

48+
!!! tip "Pro tip: Check the stage"
49+
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.
50+
4451
!!! note Note
4552
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.
4653
```bash

0 commit comments

Comments
 (0)