I used to have a java package called "Utils" and I renamed it to "utils" (uncapitalized) but it's still in the BitBucket repo. I tried to remove it using git by executing this command: "git rm src/me/lordal/gom/dtv/Utils/" but it says "fatal: pathspec 'src/me/lordal/gom/dtv/Utils/' did not match any files". So it's not in my src folder but it's still online on BitBucket.
As you can see here it has the "Utils", "Listeners" and the "Game" package two times but on the one capitalized.
Git does not do well with differences in capitalization of file names. You will need to specifically inform git that you changed the file name.
Two solutions to this problem can be found here
The first is to rename the file to some completely different name Ut-ils for example (using git mv) then change it to utils.
The second is to use git mv -f Utils utils
To fix the problem, changing the name of utils to an intermediate name then running git rm Utils (you may need to specify -r due to recursion. (The name change is necessary to make sure that git does not try to remove the proper file.)
It may be worth doing this on a fresh clone of the repo.
Try this then do the steps below.
git -rm -r Utils/
on your local repo
git add -m // adds all the stuff you want to commit
git commit -m "updated util name"
git push origin master (or whatever your branch name)
This will update the bitbucket.
Related
I'd like to write a test that
fetches which file names exist in a specific package of a remote git branch and then
checks if files with that name exist in a specific package of another remote git branch.
The test should run automatically via continuous integration.
As my project uses GitLab, solutions that use their API or similar would be feasible.
I've searched for answers and the only result I could find was this thread. However, I don't know how it could be possible to do this within an automatic test.
How could I achieve this?
If this is acceptable : the easiest way is to fetch from the two remotes, and then run your tests locally.
One way to get the content of a "directory stored in a commit" is ls-tree -r (add --name-only if you only want the filenames) :
git ls-tree --name-only -r upstream/branchname -- path/to/dir
# ^ ^
# anything that identifies a commit path to check inside that commit
We are five students in a team and we must work in the same project using git.
What i did is:
create an empty project
add gitignore file
The gitignore file
contains:
*.class
nbproject/private/
build/
nbbuild/
dist/
nbdist/
nbactions.xml
nb-configuration.xml
git init
git add .
git commit -m "Initial commit"
set up the remote and push
But we have a conflict in nbproject/private/private.properties file.
This file contains:
user.properties.file=C:\\Users\\Houssem\\AppData\\Roaming\\NetBeans\\8.2\\build.properties
user.properties.file=C:\\Users\\ASUS\\AppData\\Roaming\\NetBeans\\8.2\\build.properties
One of us he had cloned the repository and he can't add any java class in his local project.
You have confirmed in a comment that the output of git ls-files | grep nbproject/private/ contains line.nbproject/private/private.properties.
That means the file line.nbproject/private/private.properties is part of the repository.
You need to remove the file with git rm line.nbproject/private/private.properties,
and then commit the changes.
After that none of your collaborators should get any conflicts on this file.
Having nbproject/private/ in the .gitignore file should normally prevent line.nbproject/private/private.properties from getting added to the repository.
But it's possible that the file was added to the repository before .gitignore was created,
or that one of the collaborators force-added it (git add -f ...).
If possible, you might want to set up NetBeans to keep the project workspace (I believe this is called "Project" in NetBeans) outside of the actual repository and code, since this contains absolute references and (I'm assuming here) personal preferences.
I have no experience with NetBeans, but in Eclipse this works just fine.
Keeping the workspace files separate should also allow each developer to use an editor of his or her choice instead of being locked to one.
I have recently started working with a friend on eclipse, using Processing.
All the commits are fine and we can Push and Pull them correctly, but there is one problem:
We import an external jar from proccessing ("Core.jar") which is saved on each one of ours computers.
Every time that we Pull a new commit, ("Core.jar") directory changes and we have to remove the jar and reload it so we can Run the code.
Ive searched about gitIgnore but I do the ("Reset Option" and the "Ignore option") but it doesn't seem to work since the Jars problem is again.
I use Github Desktop.
As commented, if that jar is versioned instead of being generated or loaded, you should remove it from the repo first:
You can open a command-line from GitHub Desktop, and type:
git rm --cached -- Core.jar
git add .
git commit -m "record Core.jar deletion"
git push
Then your .gitignore rule should be immediately effective.
Said .gitignore should include "*.jar", or at least "Core.jar" (without the double-quotes)
As an example I have a resource folder named as;
src/test/resources/logic/myLogic/
When I have a commit that renames this structure to
src/test/resources/logic/mylogic/
This change is being ignored, and fails my Jenkins builds on *nix servers, due to the case sensitivity. Currently I do two extra commits to remedy this issue; first I delete the folder completely, commit, then insert the modified folder names, commit. This way it works, but is there no shorter route to this?
The correct way is to use below command:
git mv --force src/test/resources/logic/myLogic/ src/test/resources/logic/mylogic/
and then commit and push. But note that it is available only from Git 2.0.1.
In case you are on an earlier version of Git, then below sequence of commands can be used:
git mv src/test/resources/logic/myLogic/ src/test/resources/logic/myLogic2/
git mv src/test/resources/logic/myLogic2/ src/test/resources/logic/mylogic/
then commit and push.
I performed number of steps (some mistakes and then correcting them as shown below) and it's now causing issue in Eclipse resulting in not allowing me to switch from master to branch1.
Below is the sequence of steps:
Created master branch and pushed code including .project file by
mistake.
Created branch1 from master and pushed some code there.
Realizing mistake that .project file need not be committed, I switched back to master branch and used
"git rm --cached .project" command to remove that file from repo. Though
on terminal, it showed "rm '.project'", it would still show on bitbucked
repo.
That gave me impression that the file was not removed from repo so I
went to Bitbucket UI and removed that file externally from bitbucket
(.project -> Edit -> Delete).
That deleted my file from repo.
Went back to Eclipse and made a pull request from Eclipse itself. No error was shown.
But now
when I switch to branch1 from master, it's not allowing me to switch
and shows the error:
I put that file in .gitignore file as well (by including /.project) and pushed .gitignore but in vain. It gives me options of "Reset", "Commit" and "Stash" but unfortunately none of them works probably cause git knows this file as "ignored file" / "untracked file". I tried all of them one by one (quite a few times) but this pops up all time.
Any help would be greatly appreciated.
I'm not sure if this is the "ideal" answer but I think, from the command line, you could do a forced checkout of branch1 from master, do a git rm of the .project file and then push the change (the deletion of the .project file) to the remote repo. So it would look something like this:
git checkout -f branch1
git rm .project
git commit -m "Deleting .project dir"
git push origin branch1