Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

with_temp_working doesn't appear to do anything #280

Closed
jantman opened this issue Mar 3, 2016 · 3 comments
Closed

with_temp_working doesn't appear to do anything #280

jantman opened this issue Mar 3, 2016 · 3 comments

Comments

@jantman
Copy link

jantman commented Mar 3, 2016

I'm trying to use .with_temp_working but it doesn't appear to actually do anything.

If I have a small ruby script in a directory that's a git clone, and it does:

require 'git'
g = Git.open(Dir.pwd)
g.with_temp_working do
  g.checkout('mybranch')
end

When the script exits, I would expect my directory to be untouched, i.e. exactly as it was before. However, pwd seems to have had "mybranch" checked out.

As far as I can tell, with_temp_working is either completely unfinished, or I'm very confused about how it's supposed to work...

@robertodecurnex
Copy link
Contributor

Hi Jason,

A couple of things to have in mind:

  1. Working Directory != Working Tree
  2. git checkout branch_name != git checkout branch_name -- path_here

From Git Commit Docs:

If no paths are given, git checkout will also update HEAD to set the
specified branch as the current branch.

So, checking out a branch will update the index reference, no matter wher
your current working directory is.

Checking out files is a different story.

You can try to play with *with_temp_index *in you want to leave the
original index untouched.

Regards,

Roberto Decurnex

On Thu, Mar 3, 2016 at 3:28 PM, Jason Antman notifications@github.com
wrote:

I'm trying to use .with_temp_working but it doesn't appear to actually do
anything.

If I have a small ruby script in a directory that's a git clone, and it
does:

require 'git'
g = Git.open(Dir.pwd)
g.with_temp_working do
g.checkout('mybranch')
end

When the script exits, I would expect my directory to be untouched, i.e.
exactly as it was before. However, pwd seems to have had "mybranch"
checked out.

As far as I can tell, with_temp_working is either completely unfinished,
or I'm very confused about how it's supposed to work...


Reply to this email directly or view it on GitHub
#280.

@jantman
Copy link
Author

jantman commented Mar 4, 2016

Ok, thanks, sorry for my confusion. I'm still sort of unclear about what with_temp_working is supposed to do, but now I'm pretty clear it's not what I want.

Thanks. I'm working on an alternate solution to my problem now; I'll close this once I have it solved (and comment with a bit about what I was trying to do, and how I did it).

@stale
Copy link

stale bot commented Apr 1, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Apr 1, 2018
@stale stale bot closed this as completed Apr 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants