Git pull with reference libraries the path keeps changing - eclipse

I am working on the same project with another person, and we sync our work using Git. Whenever we do a git push / git pull the paths to our external libraries are updated with paths that are valid only for the other person's machine. The paths are defined here:
I have nothing in my .gitignore file. How can I fix this issue?

You have committed some files to your Git repo that are designed to be user-specific, and should not have been committed.
Add a .gitignore file containing at least the following:
.metadata
.classpath
Or better, import one from e.g. gitignore.io.
To remove the files you have already committed to the repo:
git rm --cached -r .metadata
git rm --cached MyProject/.classpath
and commit the changes (including your .gitignore).
The git rm commands will remove the files from the repo, but not from your working directory, so Eclipse can still find them. However, the files will be deleted from the working directory of anyone else who pulls this commit. To work around this, after the other devs have pulled your changes, you can have them do e.g.:
git checkout HEAD^ -- MyProject/.classpath
git checkout HEAD^ -- .metadata
# Unstage the files, if necessary.
git reset HEAD -- MyProject/.classpath
git reset HEAD -- .metadata
After all of this, you should be able to modify those paths per-user, and the changes will not be tracked by Git.

Group the Selenium jars into a User Library that you can reference from the .classpath file, but define differently on each machine. It adds a layer of indirection that you seem to need. http://help.eclipse.org/neon/topic/org.eclipse.jdt.doc.user/reference/preferences/java/buildpath/ref-preferences-user-libraries.htm?cp=1_4_2_0_1_1

Related

Github - Untracked Files

I'm trying to commit my project using git commit -m "First.". But throw this error, remembering that I wrote git init.
Other version control systems simply commit whatever files have been changed. Git is different. You must first build the commit by adding them to the staging area with git add. Then you git commit what has been added. This allows you to do some very powerful things, like split big changes into multiple commits.
For the above, add everything with git add . then you can commit. Though you probably want to add .vscode, tmp/, *.lock and any other temporary files and directories to your .gitignore file.
For more, please read Git Basics - Recording Changes to the Repository.

Github folder not being committed fully

Sadly I've been at it for 3 hours trying to commit my assignment which is a single folder... This is my private github repo
I can't drag the folder since it's limited at 100 files apparently there's like 4000 in my folder?
What I've done is:
$ git clone githuburl
(i now dragged my assignment folder to this repo in my own pc)
$ git add assignmentfolder (pages)
$ git commit -m "first commit"
$ git push origin master
And as you can see it straight up ignored every single file and just committed the folder name?
I think the proper way to do this is:
git clone githuburl
cd githubfoldername
then move all your files there
add a .gitignore file there and exclude node_modules and everything else that has to do with caching and external packages because you don't need them in your repo. Everyone who is going to use your code will be able to install the packages as you did. Just make sure you include the:
packages.json if you used npm
or yarn.lock if you used yarn
Then you can safely
git add --all
git commit -m "your message"
This way you will avoid adding useless files to your repo as #Dmitri Sandler said and you will be able to push everything easily
Generally you should think about files not folders. Try to use wildcard in the path:
git add <folder>/*
It is a good idea to use git status to see what files were staged for commit prior to committing them.

Removing whole directories in Github

I apologize if this seems like a newbie question, but I'm having some issues navigating through github. I understand the essentials of committing, pushing, peeling etc, but for some reason I can't figure out a few other essentials. If you could take a look at this link it's the GH repo I'm speaking of: https://github.com/AustinTice/JobInterviewAlgorithms . I have pushed new code to the file in the FizzBuzz directory, however the Algorithms/FizzBuzz directory and its containing folders are still on the remote repo although not on my local repo. I just need to know how to delete those directories, and how to essentially get better at rearranging the hierarchies of my repos.
In case clarification is needed, what I'm trying to do in the repo is have [Name of Algorithm] > [Language used to solve] > [Solution] and I need to know how to delete the whole directories, because I'm having some issues.
After deleting the folder, all you need to do is stage the changed and commit.
rm -rf Algorithms
git add <changed files>
git commit -m <commit message>
Once done, you can push the commit to the remote repository and the changes will be reflected on Github.
git push origin master
Let me know if this helps.
you should be able to delete the remote branch with following command
git push origin --delete Algorithms/FizzBuzz

Prevent newly ignored files from changing on git checkout

I have the following situation: My git repository had broken .project files checked in previously, and we wanted to remove them as they cause all sorts of importing issues. So I created a branch, where I removed all the .project files, added ".project" to .gitignore, and had planned to merge it into master, have all the developers pull down the latest update, and reimport. I've tested this and it works fine...new metadata (ie .project) files are created by Eclipse, but are ignored because of the .gitignore change.
The problem is, if a developer switches to one of their issue branches which was created pre-fix, that branch will still have the old (incorrect) .project files, which when checking out will overwrite what eclipse just generated in their working directory. This breaks everything...
I tried "update-index --skip-worktree" and "--assume-unchanged", but it wouldn't work properly, I assume because these files were no longer in the index and were ignored. Is there any way, short of merging master back into all of their branches before telling them to reimport everything, that I can resolve this?
Thanks.
EDIT: I should note, while I'm pretty experienced with git, the developers on my team are complete novices. So ideally any solution would be one that I could do on the repo side, and they could just click "pull" and have everything work automagically. If there was a single command that they could run through the SourceTree console, that might work too...
Likely, if you can negotiate with all users of your repository, then the most suitable way for you would be to rewrite the whole repository, erasing the file completely. Use git filter-branch, something like this:
git filter-branch --tree-filter 'rm -f .project && \
if ! test -f .gitignore || ! grep -q "^\.project$" .gitignore; \
then \
echo .project >>.gitignore; \
fi' -- --all
If your repository is large enough then you probably wish to use --index-filter instead of --tree-filter because --index-filter operates directly on git DB without checking out of every commit in the repository. But the script for --index-filter is more complex and cumbersome.
Then, after repository is rewritten and you have checked that every commit in every branch received desired changes, then all developers should re-fetch the repo. It would be better to ask them to push all their local changes to the repository before you start to minimize the work of rebasing when they receive the modified repository.

How to correct remote GitHub repos with gitignore?

I am using Eclipse for local dev and GitHub as my remote git repo. Eclipse generates several artifacts that I don't want in my remote repo, but I forgot to add those to my .gitignore file. I pushed everything to the remote GitHub repo and realized that the following items were pushed (again, unintentionally):
myapp/
<lots of other stuff>
.classpath --> undesired
.settings --> undesired
.project --> undesired
bin/ --> undesired
So I went back and added the following to my .gitignore:
# Eclipse
.classpath
.project
.settings
bin/
I then committed & pushed. To my surprise, the files are still in my remote repo. I would have expected the following behavior:
I push the .gitignore changes to GitHub
GitHub sees that there are files in its myapp repo that violate the terms of the new .gitignore
GitHub deletes these files/directories from the repo
Now when I go to myapp on GitHub, I don't see them anymore
Is this not the case? What's the fix here?
Git does not parse .gitignore file on each commit on it and, of course, does not apply changes from .gitignore to the whole repository in its commit.
So you need to remove files manually (git rm).
If you need to have this files on your filesystem use git rm --cached