Reputation: 3
I am new to git, I have many versions of a project stored in my local computer I wish to do the following
pl. help
Upvotes: 0
Views: 145
Reputation: 3022
Create a new directory, henceforth x
, and cd x
. Then run git init
. This will start a new empty git repository inside the x
directory. A git repository is a folder that has a .git
subdirectory.
Copy the files from the first version of your project, paste them inside x
.
Create a .gitignore
file inside x
and tell it which files of the project you do not wish be tracked by git. See here for more info.
After you're done, run git add -A
to tell git to track all the files in the directory and prepare them for committing (this will add all files except for the ones mentioned in .gitignore
).
Now run git commit -m "This is the first version of my project"
Now for the second version - completely overwrite all the files inside x
with the files of the second version (by deleting everything except for .gitignore
and .git
and pasting the files of the second version). Then performs the commands similar to before:
git add -A
git commit -m "Second version of my project"
.
Repeat these steps for all versions - overwrite files, git add, git commit, repeat.
You now have a local git repository, with each commit corresponding to a version of your Java project.
You can see the differences between the versions using the git diff
command or a Git GUI tool of your choice tool which allow you to explore your newly created repository.
You can now also upload your repository to a Git hosting service of your choice (popular ones being Github, BitBucket, GitLab and more) by creating an empty repository inside those services and adding it as a remote in your local repository and pushing the master branch (thus syncing the local copy of the repository with the remote host).
Note that this could be automated if you have a lot of versions, but such automation would largely depend on how your current "folder versioning" is structured, so this is up to you.
Upvotes: 1