automated change management / version control - version-control

I'm looking for a tool (Windows) that indexes the contents of (clear) files in a directory and keeps a history of the changes made to these files.
This could be done persistent or in batch.
If possible it should include an integrated compare-tool so previous versions can be compared.
It's basically the Eclipse "Local history" view but as a separate tool.

Initialize a Git repository in that folder and create a scheduled task that runs git commit -am "periodic commit" every X minutes (depending on the change rate). Then you can use the native history and diff capabilities of Git as you see fit.

Related

What Egit actions do I take to get copy of src file TESTGIT1 from MainServerRepository into LocalServerRepo to work on?

As a new Egit user, aiming to set up version control to update the way a team manages source code without changing locations of our build and dev servers and to identify correct Egit commands to use for check in and check out code from both servers.
In a single Eclipse workspace, initially had one project without use of Egit just a basic automatic and adhoc file copy back up of changed development directory into folders with dates of backup. Promotion to the build server was done by manually copying source files and binaries, doing a diff between source on the MainServer and local server to manage any merges. Now need to implement a proper version control system, using Egit, so as a first time Egit user. I have set up two test Eclipse projects in my workspace: project A shared with MainServerRepository and project B shared with LocalServerRepo. The two git repositories will be in different directories: MainServerRepository on the network and LocalServerRepo on my area on the network where I backup my PC.
What Egit actions do I take to promote latest TESTGIT1.src from MainServerRepository into LocalServerRepo to work on in my local server? (Team > Fetch from upstream is grayed out). Then, once tested, how do I check in src for TESTGIT1 into the main build server project, source and objects are in MainServerRepository?
I've used Team > Commit successfully to check in, but am using cut and paste to move code between two projects (prior to commit) and feel there must be a better way to do this or to set up the projects differently within Eclipse.
Or should I be using Team > push or Team > merge?
Do I need local repository or should I just check out into workspace?
Any comments/ question/assistance would be welcome as haven't figured it out from reading the EGit/User_Guide.
Edit TESTGIT1.src in Eclipse project shared with LocalServerRepo(testGitRepo) until work on it is complete on local server. Then, apply same changes to TESTGIT1 in the main build server project, using right click copy +paste from right click, team > check in. Then in Git Staging view, click plus sign to add to index (staging area), then click commit button, merging in with any other changes made to TESTGIT1.src by other developers. Don't use push command to push entire contents of LocalServerRepo. Or is there a better answer?

Recover from Git reset --hard in Eclipse

I accidentally did something to my git repo and I don't know if I can save my project at this point...
I had a bunch of changes that I made. Then I wanted to delete my last commit so that I could make this new commit instead. I forgot to do git stash. So when I ran git reset --hard [second-to-last commit] it erased everything I had done. It was stupid, but is there anything I can do to rescue my recent work?
I'm using Eclipse IDE.
Short answer for git, NO.
It is impossible to recover file that you did not add or stash
In general the best way to handle these kind of problem is to rely on the IDE instead.
In Eclipse, you could look under this path
.metadata/.plugins/org.eclipse.core.resources/.history/
So, you could use those commands to find the most recent changes,
cd .metadata/.plugins/org.eclipse.core.resources/.history/
ls -al * | grep "<today's date>" | grep "r\-\-" | sort -k 6
Note that you will have to replace "<today's date>" with "Jul 27" for example.
Then you could use
find . -name <filename>
Note that you will have to replace "<filename>" with something like "7098a672a2bc00111703c0e5cbee369d" found with the previous command.
For more info look at this.
Unfortunately, git has no way of knowing about the file contents that you didn't commit or stash. This means you cannot restore your changes with git. Other tools might be able to help. For example, IntelliJ has a "Local History" feature that tracks all saved changes. Perhaps your editor has something similar?
You mentioned in your comments that you were using Eclipse - normally eclipse keeps a local history of changes that you were and have been making. The following steps may help in that regard:
Restoring deleted resources from local history
To restore a deleted Workbench resource with a state from the local history:
In one of the navigation views, select the folder or project into which you want to restore a local history state.
From the resource's pop-up menu, select Restore from Local History.... The Restore From Local History dialog opens showing all files that were previously contained in the selected folder or project and all of their sub-folders.
Check the files that you want to restore
If you don't want to restore just the last state of a file you can select any other state of the file from the Local History list on the right hand side of the dialog. The bottom pane of the dialog shows the contents of the state.
If you are done with all files click Restore.
Tip: You can configure your Workbench preferences to specify how many days to keep files, or how many entries per file you want to keep, or the maximum file size for files to be kept with the command link General > Workspace > Local History preference page.
this can also be found at this link: https://help.eclipse.org/neon/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Ftasks%2Ftasks-87b.htm

How to view file changes before pulling through GitHub on RStudio?

I'm transitioning from using Subversion in Eclipse for code management to GitHub in RStudio. It's starting to make sense, but I can't seem to figure out how to pull effectively.
Specifically, if I use the Pull arrow in RStudio, every file change in the repository automatically updates my local files without warning. I can see how many files were updated, but not what changed!
Here are the questions I'm hoping to get help with:
1) Can I preview the repository file changes in RStudio before I pull them locally? With SVN in Eclipse, there was an indicator showing files with a difference, and the option to view side by side.
2) If multiple files have been changed on the repository, is it possible to pull just 1 locally?
3) How can I revert a local file to a previous version?
Right now I've been trying to do this all within RStudio for simplicity. I haven't used things like the GitHub desktop client.
I appreciate the help!
I would suggest you better get used to the git's own tools to stay informed about your repository.
For example you could do following.
Before you pull, check your current commit logs
git log
This should show you how your current commits stack up. Note the latest commit id (first 4-5 letters would usually do)
Now after pulling you can see the difference using following command
git diff --color your_previous_commit_id..HEAD
If you don't like the changes and want to go back,
you can just reset to your favorite commit with following command. BTW run "git stash save" to keep a copy of your uncommitted changes.
git reset --hard you_favorite_commit_id
Note: that this will delete all your uncommitted changes unless you stashed them and put your local branch behind the remote repo branch you are tracking again.
Wondering where to put these commands? Check https://git-scm.com/downloads.
What's good about using these git tools is that if you switch between IDEs you don't need to search for same functionalities you had in your earlier IDEs.

Adding TeamCity build configurations to (proper) source control

We have over 100 build configurations in Team City, and I've come to realize over the past few months that these assets are just as important (if not more so) than the actual project assets (code, config, etc) we are delivering.
To that end, I know TC provides it's own build configuration version control but to me that seems a bit low on features - for example if a build stops working it would be really good to be able to diff the actual XML build configurations in my favorite diff tool rather than rely on TC's built in one, or to be able to view differences across a longer time frame than simply against the previous state.
Obviously this can be handled manually by extracting the build definition and committing, and then applying self disciple to always do this when you change the definition. Can anyone suggest a more joined up approach? We're using TeamCity Enterprise v8.0.5
Can you upgrade to TeamCity 9? TeamCity now has built in support to sync the build configurations to Git or Mercurial.
https://www.jetbrains.com/teamcity/whatsnew/
https://www.youtube.com/watch?v=zTLeCrdxGIw
As an interim solution before you upgrade to TeamCity 9, you could write a scheduled job to run every 10mins (or even every minute) and automatically commit the changes to a new repository. I'd use a new repository so TeamCity doesn't ever try and trigger off the commits.
I don't know what OS or VCS you are using, but you'd just need to commit all XML files so you get project-config.xml, build type XML, and plugin config, you don't want .properties files as the build number files will change after every build.
<TeamCityData>/config/projects/**/*.xml
If you are using Git you could easily just init a repo in the projects directory, add a .gitignore for anything other than *.xml, and run git add . and git commit -m "Build configuration settings were edited" as a scheduled job.

Eclipse: How to export local history to a real SCM system like Git or SVN

I have an Eclipse project which started out as a smallish, quick'n'dirty, private hack. I did not bother to use a real SCM (source code management) system like Git or SVN, not even locally. What I have instead is a few days' worth of Local History, an out-of-the-box Eclipse feature. As so often, the project grew and I want to share it including history, because the history shows a lot of refactoring steps which come in handy as a showcase in order to teach someone else about refactoring, clean code etc.
I already know that I can manually retrieve old versions file by file and manually migrate them to e.g. a Git repository, committing changes one by one and file by file. But what I am really interested in is:
Can I reset the whole project (not just a single file) to a certain date using Local History?
Is there a way to export certain (or all) snapshots of the local project history, so I can commit them to Git snapshot by snapshot?
Is there even an option (or an external tool, script etc.) by means of which I can automatically migrate a project's local history to a real SCM system like Git (preferred) or SVN? It would also be okay if the tool just created lots of full project snapshots in subfolders named by timestamps.
Disclaimer: Yes, I do know that I should have used Git right from the start. It would have cost me just three minutes to set up a local repository etc. But... BUT. You know. ;-)
I don't think there is, but keep in mind that the task shouldn't be too tedious.
Make a copy of your project before starting, just for safety's sake and then:
git init
(revert to snapshot 1)
git add .
git commit -m "First snapshot commit"
(revert to snapshot 2)
git add .
git commit -m "Second snapshot commit"
Wash, rinse, repeat.
If you've only got a few dozen snapshots, it shouldn't take more than an hour or so to do, which is probably a lot less than it would take to figure out a programmatic solution.
Unfortunately, the answer is "no" to all of your questions. At least, using standard built-in Eclipse functionality; there's always a chance that someone has written a plugin that meets your needs, but in this case I'd be surprised. Check the Eclipse Marketplace (found under the Help menu).