I have recent migrated a Java EE project from 5 to 6, as this required quite a big overhaul I created a new EE6 skeleton project and copied most of the code across manually. I now have my working EE6 project (and an obsolete EE 5 project).
I would like to keep my Git history, is there are recommended way to move the .git directory into the new project so that all the updates are picked up as a new commit? Or can I just copy the .git folder over? Or do I have to start from scratch and lose the history?
Thanks, I am sure this must have been asked before but I have been unable to find any questions that relate
You can copy the .git folder in the new project, and check that a git status does pick up all your changes (git add -A . after that, in order to add any new, modified or deleted files).
A more clean solution would be to :
initialize an empty git repo in your project (git init .)
add as a remote a path to your previous project (git remote add origin /path/to/previous/project, where a .git/ folder reside.
Then, using git branch and git reset:
git fetch
git branch master origin/master
git reset --soft master
Related
I added Maven support to a project that previously did not have it. IntelliJ then moved all the java files, but even though it's a git project, did not use git mv and so there's no file history.
How do I fix this?
Example:
//The below structure was before Maven
/src
.../com
.../test
.../SomeClass.java
//After Maven
/src
.../main
.../java
.../com
.../test
.../SomeClass.java
Renames are not first class citizens in Git.
Git detects renames based on file content changes.
As such, the main purpose of git mv is to simplify staging.
If files get renamed without git mv,
that causes only a minor inconvenience,
which you can rectify by appropriate git add commands.
That is, for each renamed file, one git add for the old name ("deleted file" from the perspective of Git), and one git add for the new name ("new file" from the perspective of Git).
In your particular example,
a simple fix could be staging everything by running git add . at the project root.
After that, check the output of git status -sb.
There's a good chance that Git will figure out all the renames.
I have a Java project managed in SVN. This project has a remote folder - say - bin. When I create a branch from trunk, svn cp command is not copying this remote folder, but instead, it maintains the link back to the trunk. So, if somebody makes a breaking change on this file in trunk, then it is automatically reflects in feature or release branches and causes problems.
Is there a way to force SVN to copy this remote folder and all the contents under it? Or is there any other feature in SVN that lets me do this?
I am a newbie in dealing with Git. I am using Git in eclipse.
My main project contains the google-play-services_lib has a library project.
Recently I did Git -> Fetch from remote repository and now when I do Git -> Pull in main project, I get conflicts in google-play-services_lib which I never changed (generated files changes).
I want to ignore the library project changes from Git pull in eclipse.
Whenever I take Git pull from main Project, I always get the following conflict in eclipse-
Checkout conflict with files:
google-play-services_lib/bin/AndroidManifest.xml
google-play-services_lib/bin/R.txt
google-play-services_lib/bin/google-play-services_lib.jar
google-play-services_lib/bin/jarlist.cache
So though these conflicts are system generated changes, I always want to ignore them.
I used Team -> Disconnect on google-play-services_lib, but this only disconnected me from Git for the library google-play-services_lib.
I used Team -> Ignore on google-play-services_lib, but this did nothing in resolving conflicts.
I used Team -> Untrack on google-play-services_lib, but this added all files in google-play-services_lib in the conflict state.
Try the Options Assume unchanged and Assume changed:
Assume Unchanged to all of the generated files
Pull
Assume Changed to all the generated files
Because this will get very annoying if you have to do it for every commit, you could write a Script to handle this. The required commands are:
git update-index --assume-unchanged <file>
git update-index --no-assume-unchanged <file>
i am facing problem in importing project from github i.e,remote repository.it is giving no project found.and found the reason i should push .project and .classpath files also then only it will recognise the java project.but how to push them.
and i have 1more question
can i push more than 1 project into the remote repository.
i used following commands to push into the repository
git add .
git commit -m "intial commit"
git remote add swathi "https://github.com/swathiananthula/samplerepo.git"
git push swathi master
can anyone help me?
how can I import the project successfully into STS.
Remove .project and .settings entries (or any project config) from the .gitignore file and use git add . and git push.
The next time someone clones your repository they would be able to import it as a project.
Just note that though if you check in project files, make sure you don't have machine specific entries in your project settings as it will differ for each developer. This includes any classpath entries with full paths etc.
For your initial question; yes you can have multiple projects in one repository, though many would not recommend it.
I already have an existing project in Eclipse that I want to add to my team's github repo. The github repo is empty right now. What's the best way to add this project to our github repo? I was thinking of git cloneing our repo into the workspace folder (parent to the project in question) and then adding the project files using git add, then pushing the changes. Would that work, or is there a better way to do this (perhaps with EGit)?
You have to add a remote to the project, and then push to it.
For example, you can do (from inside the project directory)
git init # if you haven't already
git remote add origin ssh://git#github.com:.....
git push -u origin master
there should be a way to do that from the eclipse plugin too, but I find it easiear to do it from the command line.. :)
By the way, remember to add all the IDE-specific files to .gitignore, to avoid pushing garbage to the world: they usually are .project, .classpath and directories like bin/*,.settings/* ...