Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ducktordanny/git-worktrees-presentation
Get to know git working trees
https://github.com/ducktordanny/git-worktrees-presentation
Last synced: 26 days ago
JSON representation
Get to know git working trees
- Host: GitHub
- URL: https://github.com/ducktordanny/git-worktrees-presentation
- Owner: ducktordanny
- Created: 2023-09-07T20:12:18.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2023-09-08T11:30:36.000Z (about 1 year ago)
- Last Synced: 2023-09-08T12:41:38.336Z (about 1 year ago)
- Language: CSS
- Homepage: https://ducktordanny.github.io/git-worktrees-presentation/
- Size: 2.44 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Git Worktrees Presentation
> Get to know git worktree: What is it? What to use it for? Why is it great?
## Introduction, and the problem
See the [link](https://ducktordanny.github.io/git-worktrees-presentation/) in the About section of the GitHub repo.
## Demo
1. Clone bare repository:
```sh
git clone --bare [email protected]:ducktordanny/git-worktrees-presentation.git
cd git-worktrees-presentation.git
```2. Because we fetch the bare repo, check:
```sh
git config --get remote.origin.fetch
```If this does not return anything, or it doesn't return "+refs/heads/*:refs/remotes/origin/*", then:
```sh
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
```Why is this needed? Well git clone --bare does two things:
- it makes a bare repository that has no work-tree and does no initial checkout
- it changes the default fetch refspec from +refs/heads/*:refs/remotes/origin/* to +refs/heads/*:refs/heads/*So we have to set it manually. Otherwise, fetch and pull might not work when you want to access new changes.
3. Create working trees
E.g.:
```sh
git worktree add feature-1
git worktree add review-stuff
git worktree add random
```Then it will create the "feature-1", "review-stuff" and "random" folders, each having its own repo files, and we can easily just cd into them and out of them.
- Navigate inside "feature-1", start to implement your feature.
- While there is something that you have to check in another branch for your coworker, just leave everything as it is and `cd` into the "random" folder, and then checkout the needed branch from there.
- After you finished, just `cd` back and continue.