Skip to content

Commit b6ec0a8

Browse files
authored
Update Git basics and how I work with Git (#186)
* Update Git basics and how I work with Git * Add link to bash PS1 trick * Fix linting
1 parent cdfb5d2 commit b6ec0a8

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

01_version_control/git_basics_demo.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,31 +37,31 @@ Starting remarks:
3737
- fork -> my fork
3838

3939
- (2) Working directory:
40-
- ZSH shell shows git branches
40+
- ZSH shell shows git branches. There are [similar solutions for Bash](https://coderwall.com/p/fasnya/add-git-branch-name-to-bash-prompt) as well.
4141
- `git remote -v` (I have upstream, myfork, ...)
4242
- mention difference between ssh and https (also see GitHub)
4343
- get newest changes `git pull upstream develop`
44+
- or simply `git pull` (`git branch -vv` to see upstream tracking)
4445
- `git log` -> I use special format, see `~/.gitconfig`,
45-
- check log on GitHub; explain short hash
46-
- `git branch`
47-
- `git branch add-demo-feature`
48-
- `git checkout add-demo-feature`
46+
- check log on GitHub
47+
- explain how hash is computed (complete state + pointer to parent)
48+
- explain short hash
49+
- `git checkout -b add-demo-feature`
4950

5051
- (3) First commit
5152
- `git status` -> always tells you what you can do
5253
- `vi src/action/Action.hpp` -> add `#include "MagicHeader.hpp"`
5354
- `git diff`, `git diff src/com/Action.hpp`, `git diff --color-words`
5455
- `git status`, `git add`, `git status`
5556
- `git commit` -> "Include MagicHeader in Action.hpp"
56-
- `git status`, `git log`, `git log -p`, `git show`
57+
- `git status`, `git log`, `git show`
5758

58-
- (4) Change or revert things
59+
- (4) Change or reset things
5960
- I forgot to add sth: `git reset --soft HEAD~1`, `git status`
6061
- `git diff`, `git diff HEAD` because already staged
6162
- `git log`
6263
- `git commit`
6364
- actually all that is nonsense: `git reset --hard HEAD~1`
64-
- modify again, all nonsense before committing: `git checkout src/action/Action.hpp`
6565

6666
- (5) Stash
6767
- while working on unfinished feature, I need to change / test this other thing quickly, too lazy for commits / branches
@@ -70,7 +70,6 @@ Starting remarks:
7070

7171
- (6) Create PR
7272
- create commit again
73-
- preview what will be in PR: `git diff develop..add-demo-feature`
7473
- `git push -u myfork add-demo-feature` -> copy link
7574
- explain PR template
7675
- explain target branch
@@ -87,13 +86,17 @@ Starting remarks:
8786
- `git checkout -t alex/[branch-name]`
8887
- I could now also push to `ajaust`'s remote
8988

89+
- (8) GitHub CLI
90+
- `git push -u ...` and `git pull -t ...` maybe hard to remember at first.
91+
- Things get easier with the [GitHub CLI](https://cli.github.com/), but bound to GitHub, obviously.
92+
9093
## Further reading
9194

9295
### Quick things
9396

9497
- [Video: Git in 15 minutes: basics, branching, no remote](https://www.youtube.com/watch?v=USjZcfj8yxE)
9598
- [The GitHub Blog: Commits are snapshots, not diffs](https://github.blog/2020-12-17-commits-are-snapshots-not-diffs/)
96-
- Chapters [6](https://merely-useful.tech/py-rse/git-cmdline.html) and [7](https://merely-useful.tech/py-rse/git-advanced.html) of Research Software Engineering with Python
99+
- Chapters [6](https://third-bit.com/py-rse/git-cmdline.html) and [7](https://third-bit.com/py-rse/git-advanced.html) of Research Software Engineering with Python
97100
- [Podcast All Things Git: History of VC](https://www.allthingsgit.com/episodes/the_history_of_vc_with_eric_sink.html)
98101
- [git purr](https://girliemac.com/blog/2017/12/26/git-purr/)
99102

0 commit comments

Comments
 (0)