brain/src/dev/tools/git.md

51 lines
976 B
Markdown

# Git
## Fetch a remote branch
- 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
```
## Amend without editing commit message
```shell
git commit --amend --no-edit
```
## Copy current HEAD sha sum to clipboard
```shell
git rev-parse HEAD | xclip
```
## 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.
## Switch to previous branch
```sh
git checkout -
```