1

Quite new to git and mac.

But I'm using the Git Plus in Atom to handle all my version control via git. But I'm having a lot problems if I add components/libs via bower to my ionic project.

Working on branch quick_fix and adding a angular-cookies (ionic stores it in a folder called lib). Update the code and do some commits.

Had some problems doing it in Atom after using bower, so try the terminal. So I do the following in the Terminal:

git checkout master

warning: unable to unlink www/lib/angular-cookies/.bower.json: Permission denied
warning: unable to unlink www/lib/angular-cookies/LICENSE.md: Permission denied
warning: unable to unlink www/lib/angular-cookies/README.md: Permission denied
warning: unable to unlink www/lib/angular-cookies/angular-cookies.js: Permission denied
warning: unable to unlink www/lib/angular-cookies/angular-cookies.min.js: Permission denied
warning: unable to unlink www/lib/angular-cookies/angular-cookies.min.js.map: Permission denied
warning: unable to unlink www/lib/angular-cookies/bower.json: Permission denied
warning: unable to unlink www/lib/angular-cookies/index.js: Permission denied
warning: unable to unlink www/lib/angular-cookies/package.json: Permission denied

So these files are now still in the folder... even though that I'm back to the master code that doesn't have the hot fixes...

git status

On branch master
Untracked files:
  (use "git add <file>..." to include in what will be committed)

    www/lib/angular-cookies/

If I try to do a merge I get the following

sudo git merge quick_fix

Updating 034f577..8b74fa5
error: The following untracked working tree files would be overwritten by merge:
    www/lib/angular-cookies/.bower.json
    www/lib/angular-cookies/LICENSE.md
    www/lib/angular-cookies/README.md
    www/lib/angular-cookies/angular-cookies.js
    www/lib/angular-cookies/angular-cookies.min.js
    www/lib/angular-cookies/angular-cookies.min.js.map
    www/lib/angular-cookies/bower.json
    www/lib/angular-cookies/index.js
    www/lib/angular-cookies/package.json
Please move or remove them before you can merge.
Aborting

How do I do a merge?

I think that the problem has to do with doing a checkout to master without doing sudo. So I'm not giving it permission to delete the folders.. Is there any way I can give permanent sudo permissions to delete files in this working directory - so the Atom editor can do a checkout to master without keeping the added component..

Problem is that I can't checkout quick_fix because it gives me the same error and aborts.

Zoe
  • 27,060
  • 21
  • 118
  • 148
Norfeldt
  • 8,272
  • 23
  • 96
  • 152
  • 1
    In the working directory: `sudo chown -R $(whoami) ./www/lib` will bring you the right permission! – dNitro Jul 16 '16 at 08:52
  • @dNitro after doing what you suggest I ran into the following problem https://discuss.atom.io/t/atom-helper-wants-to-make-changes/17260 – Norfeldt Jul 17 '16 at 15:57
  • At least now we know that its not a *git* problem nor a *bower*'s one! It's all about peimission. And seems your Atom is not running with right permissions so every time you ask it for a change it examines your identity! – dNitro Jul 17 '16 at 16:23
  • @dNitro how do I reverse it...? – Norfeldt Jul 17 '16 at 16:45
  • Of course we does not do anything harmfull, by this command we just **ch**anged **own**ership for *lib* directory and all of the files and subdirectories contained within(**-R**) to **$(whoami)** variable. you can see the value of this var by doing `echo $(whoami)`. – dNitro Jul 17 '16 at 19:20
  • To revert, in the working directory `ls -la www` to see a list of files and directories beside *lib* folder formatted like: *drwxr-xr-x 3 **User** **group** 102 Jul 16 16:41 example*. Then run `sudo chown -R User:group ./www/lib` (replace *User* and *group* with user and group of files and folders beside your lib dir) to match your *lib* dir with other ones. BUT why revert, TRY to resolve. – dNitro Jul 17 '16 at 19:20
  • thought a revert would resolve... I tried a lot and now it works.. Not completely sure what did the trick... – Norfeldt Jul 17 '16 at 19:27
  • @dNitro I did a `sudo chown -R 777 ./www` that seem to do the trick.. not sure if that was to much access to grant – Norfeldt Jul 18 '16 at 18:15
  • 1
    Great. Happy gitting :) – dNitro Jul 18 '16 at 18:37

1 Answers1

1

Had some problems doing it in Atom after using bower, so try the terminal.

That is a good idea, but you need to close Atom first, before the git checkout.
Otherwise, Atom would keep an handle on those files, which results in the error message you saw.

While in command-line, close as much other applications as possible in order to do the (clean) checkout you need.
You might need a git clean before resuming your work on your checked out branch.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250