Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding a new directory to a GitHub repository branch and merging back to the trunk

Tags:

merge

github

I'm having trouble merging a branch back to the trunk after adding a new directory.

I created a new branch BUG_BRANCH, made a few code changes, added a directory, and added several files to that directory. I used "git add ." to add my changes for committing to my local branch. Then "git commit -am 'message here'". I then pushed my branch up to GitHub "git push origin BUG_BRANCH", checked out the main development branch again "git checkout dev", and grabbed any changes that had happened since I'd created my branch "git pull origin dev".

My problem occurred when I tried to merge the changes from my BUG_BRANCH to dev "git merge BUG_BRANCH". For each file within the newly created directory, I got "error: cannot stat 'path': Permission denied". When I log into GitHub, I see my changes hanging out in the remote copy of my branch. But I can't merge them into dev, and I can't even seem to get back to BUG_BRANCH locally; I get the same error message.

Looking around on StackOverflow, it seems that I could have added the directory using the -A option of add if I could get back to my branch. But I can't. Any ideas?

like image 630
virtuesplea Avatar asked Nov 25 '25 09:11

virtuesplea


2 Answers

As mentioned in "git rebase: error: cannot stat 'file': Permission denied", this should be an error seen mainly on Windows.
It is usually related to files locked by a Windows process, either an anti-Virus or an IDE (Visual Studio, Eclipse, ...).
Make sure no other processes are running when trying to make your checkout or merge, and see if the issue persists.

TortoiseGIT process that blocks those files. Open task manager and end process TGitCache.exe.

The OP virtuesplea reports:

Killing the TGitCache.exe process (from the other topic) ended up being the solution

like image 147
VonC Avatar answered Nov 27 '25 00:11

VonC


The main problem here is that the editor/IDE is locking the file/folders. When you close the editor/ide, the file/folder will disappear and you can change branches/merge/rebase.

Different branches might contain different folders, so when branches are changed/merged/rebased, the editor/ide reloads the file system.

Maybe you did not allow the editor/ide to perform this reload or some settings are there which does not allow this. I encountered a similar problem in visual studio.

To solve this, just close the editor/ide.

like image 31
adib.mosharrof Avatar answered Nov 27 '25 02:11

adib.mosharrof



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!