brain/src/dev/tools/git.md

51 lines
976 B
Markdown
Raw Normal View History

2017-11-02 07:07:09 +00:00
# Git
2017-11-03 10:32:19 +00:00
## Fetch a remote branch
2017-11-02 07:07:09 +00:00
- Create a local branch that tracks a remote branch
```shell
git checkout --track origin/develop
```
If you want to change the name of the local branch (_NOT A GOOD IDEA_)
```shell
git checkout --track -b gniagnia origin/develop
```
2017-11-03 10:32:36 +00:00
2020-02-17 17:30:52 +00:00
## Amend without editing commit message
2017-11-03 10:32:36 +00:00
```shell
2020-02-17 17:30:52 +00:00
git commit --amend --no-edit
2017-11-03 10:32:36 +00:00
```
2017-12-05 10:48:27 +00:00
## Copy current HEAD sha sum to clipboard
```shell
git rev-parse HEAD | xclip
```
2020-02-11 12:15:53 +00:00
## Conditional Git configuration
Since git 2.13, there is an option to include configuration (or not) based on a condition
Here is an example use case
```txt
# Specific configurations for work and personnal repos
[includeIf "gitdir:~/code/work/"]
path = .gitconfig.work
[includeIf "gitdir:~/code/oss/"]
path = .gitconfig.oss
```
If include, settings in any configuration found file provided by the path
parameter will by append to or will overide current configuration.
2022-03-24 10:11:37 +00:00
## Switch to previous branch
```sh
git checkout -
```