Avatar of Bruce Gust
Bruce GustFlag for United States of America

asked on 

GIT: I'm stuck. I can't add, reset or checkout. How do I get past this?

I'm trying to checkout a branch and I'm unable to do so because I keep being told that there are some files that are going to be overwritten and then I'm later told that I don't have permission...

It's a ball of snot.

Here's the situation...

First of all, here's my status:

User generated image
The "Changes not staged for commit" aren't relevant to the work I've been doing, neither is the file that's referenced as "untracked."

If I try to checkout another branch, I get this:

b.gust@AHA-DT-BGUST2 MINGW64 /c/wamp64/www/bsmart (code-cleanup)
$ git checkout final-activity-stream
error: Your local changes to the following files would be overwritten by checkout:
        bin/start.sh
Please commit your changes or stash them before you switch branches.
error: The following untracked working tree files would be overwritten by checkout:
        .vs/slnx.sqlite
Please move or remove them before you switch branches.
Aborting


At this point, these files haven't been added or staged, correct? What I'm seeing is indicative of the files having been modified, but they've not been added let alone committed.

What do I need to do?

I can't add them:

error: open("bin/start.sh"): Permission denied
error: unable to index file 'bin/start.sh'
fatal: updating files failed

I've looked at reset and I get a permission denied.

I'm stuck.

What do I need to do?
Git

Avatar of undefined
Last Comment
Bruce Gust
Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland image

Hey Bruce,

In Git, you have a working copy - these are the files that you're currently working on. When you make changes, add files, delete files etc, you 'dirty' your working copy. In order to switch branches you need a clean working copy - you get this by committing your changes to the branch your on. If you can't do that (or don't want to do that), then you can 'stash' your changes. This is like a temporary save of any modified file - it puts them in a temporary storage areas and gives you a clean working copy. You then then switch branches as there are no longer changes on your current branch. You can later apply that stash (to any branch) if you need to pull those changes back.
Avatar of Bruce Gust
Bruce Gust
Flag of United States of America image

ASKER

Chris!

You're on point as usual. I tried that and this is why I feel "stuck..."

$ git stash
error: lstat("bin/start.sh"): Permission denied
fatal: Unable to process path bin/start.sh
Cannot save the current worktree state



Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland image

OK,

If I remember correctly, you're running on Windows right? Permissions aren't quite the same in Windows as they are on Linux, so a couple of things to try. First off - shut down your code editor (IDE), or any program that is likely to have a handle on any file in your working directly. If that doesn't solve it, restart git bash but make sure your Run as Administrator.
Avatar of Bruce Gust
Bruce Gust
Flag of United States of America image

ASKER

OK, I'm running Git Bash as Administrator and I shut down everything including Docker so I'm now able to get in the door more than I was before, but...

I'm still getting this:

$ git stash
Saved working directory and index state WIP on code-cleanup: ccecd93 lining up my base branch with the most recent edits as of April 24

b.gust@AHA-DT-BGUST2 MINGW64 /c/wamp64/www/bsmart (code-cleanup)
$ git checkout final-activity-stream
error: The following untracked working tree files would be overwritten by checkout:
        .vs/VSWorkspaceState.json
        .vs/bsmart/v16/.suo
        .vs/slnx.sqlite

Please move or remove them before you switch branches.
Aborting

The files that I have in bold are not relevant. I've stashed everything else, but these guys refuse to budge.

How do I "move or remove them?"
ASKER CERTIFIED SOLUTION
Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Git
Git

Git is a version control system for software development. It is a distributed revision control system with an emphasis on speed, data integrity, and support for distributed, non-linear workflows. Git was initially designed and developed for Linux kernel development. As with most other distributed version control systems, every Git working directory is a full-fledged repository with complete history and full version-tracking capabilities, independent of network access or a central server.

469
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo