Coder Social home page Coder Social logo

lu0 / git-worktree-wrapper Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 1.0 38 KB

Effortlessly manage Git worktrees with `git checkout` and `git branch` commands, forget you are using git-worktree!

License: GNU General Public License v3.0

Shell 100.00%
git git-worktree git-workflow git-hooks git-checkout git-wrapper bare-repo bare-repository worktree worktrees

git-worktree-wrapper's People

Contributors

lu0 avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

kedwards

git-worktree-wrapper's Issues

Can't checkout to new fetched branch

Describe the bug
Cannot checkout/switch to branches fetched from the remote, these branches were not created locally.

To Reproduce
Steps to reproduce the behavior:

  1. Let's assume we have an existing repository, cloned as a bare one.
  2. Let someone else (or you from another machine) create and push a new branch, e.g new-from-remote/test.
  3. Fetch all changes into the local repository git fetch --all .
  4. Try to checkout to the new branch git checkout new-from-remote/test.
  5. Throws the following:
    • When checkedout from the root directory of the local repository:
    fatal: this operation must be run in a work tree
    • When checkedout from an existing worktree, lets say master:
    Branch 'new-from-remote/test' set up to track remote branch 'new-from-remote/test' from 'origin'.
    Switched to a new branch 'new-from-remote/test'
    But the current directory stays the same (master).

Expected behavior
After git checkout new-from-remote/test the script should fetch new-from-remote/test, create the new worktree in <repo's root dir>/new-from-remote.test, and cd into it; even from the repo's root directory.

Desktop (please complete the following information):

  • OS: [Linux Mint 20]
  • Git version: [2.25.1]
  • Shell [Bash 5.0.16]
  • Repository version [v1.0.0]

Additional context
I think is a matter of looking for all existing local and remote references, but will need to parse only the names and not the remote specifiers (remote/heads/...)

Create worktree if branch already exists

When I want to create a new worktree, the script tries to create a new branch and fails if the branch exists (locally or in the remote).

Update the script to skip branch creation and fetch from the existing branch.

`git branch -d` doesn't seem to delete branch/worktree from git cache

Describe the bug
Title

To Reproduce
Steps to reproduce the behavior:

  1. Run git branch -d old_branch or git branch -D old_branch from git root or from the worktree directory.
  2. This doesn't seem to delete the branch and worktree from the git cache, doing git checkout old_branch re-creates the worktree directory with the files of the 'deleted' branch.

Expected behavior
git checkout old_branch should raise an error after such branch has been deleted.

Screenshots
N/A

Desktop (please complete the following information):

  • OS: Linux Mint 20, but tested on Windows 10 and Windows 11, too.
  • Git version: 2.25.1
  • Shell: Bash 5.0.16
  • Repository version: v1.1.0

Additional context
git branch -d/-D old_branch does indeed delete the worktree directory, but it's kept in the cache.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.