Is there a way to override/replace the local changes from the version controls (like svn, CVS)? In Eclipse, I can right click on the project->team->synchornize.. then it shows all changes comparing to the repository. Then, If I need to override the file, "update and override" option is there. Correspondingly, Is there such a way to replace local changes in a class or a package with one click in IntelliJ Idea?
(I found a way to compare incoming changes, then I had to get one by one changes to my local class files) . I use IntelliJ Idea community edition 15
For single file you can follow below steps :
a) Right click on file
b) Git ---> Show History
c) It will show a window in which you can see the history of changes, select a commit,right click on it. Select Get.
Link : https://intellij-support.jetbrains.com/hc/en-us/community/posts/207743285/comments/207412185
If I understand the question right, I think you need to revert your local changes then update from the remote. You can do this at a class or package level, or on the whole project.
I think it is going to be an two way process.
Revert the changes (Ctrl+Alt+Z).
Update the project (Ctrl+T).
Choose the project(if you have multiple files changed), right click -> GIT -> Compare with branch(select the branch which you want to override your changes) -> it will show the differences it detected -> click "Get" icon, it prompts "Some files were locally modified" -> choose "Overwrite Modified Files"
But sometimes it doesn't work well.
Another simple but dangerous way is to use git command:
git fetch --all
git reset --hard origin/master
(Then all your local change will be lost)
Related
I accidentally discarded 2 uncommited files from my project. Is there any way to undo these changes/bring those files back. I use IntelliJ and VS Code simultaneously. MAybe some kind of editor cache or history where I can view last hour or so changes and copy those??
I found the answer. There seems to be no way to do this using just GIT. But an Editor like IntelliJ really helps. IntelliJ maintains a local history of changes you did (even uncommitted) and you can revert to any point in time (caveat it keeps history only upto few Days).
How To Revert
IntelliJ Project tab -> rt click there -> select Local History -> Show History. Just select the point in time you want to go and revert.
This Post will also be helpful for detailed steps
https://blog.jetbrains.com/idea/2008/01/using-local-history-to-restore-deleted-files/
If you created the file using IntelliJ, you're in luck since IntelliJ will track local history of edits and allows restoration. Right click the project in the project view, and select Local History. You'll be able to find the step in which the file was deleted, and will be able to roll it back with a right-click.
In Eclipse, when click Synchronize view it will show up a tree structure of diff comparison from local to svn repo. Click on each file will pop up view to show code diff.
Is there a similar feature in Intellij and how to activate it? I am on latest Intellij Ultimate btw.
Click on the Version Control button on the bottom, click on the Incoming tab. Hit the refresh button (circle with arrows). First time it will ask you if you want to set up automatic refresh. It will then show any changes pending from the repository. You can click on files and get a diff. (You may have to right click on a revision and select "Show Affected Files".)
There is no exact same view in IDEA. See https://youtrack.jetbrains.com/issue/IDEA-119596
You can use Subversion -> Compare to the Latest repository version from a file's context menu.
There is also the Incoming tab that shows changes from the server not yet applied to your working copy. You could invoke Show Diff with local from the Details pane of the Incoming change
I've been working on a project for a few months using branches, and branches from branches to allow me to roll back to various points. I realise this may not be best practise!
I tried merging into master and got hundreds of errors so instead removed all branches except the current one. Again that might have been bad.
I'd now like to make the current branch the master but a number of files have version control symbols next to them and will not commit.
I tried Product->Clean but is there a way to effectively say to xcode 'make this the master and track all changes from now'. I don't even mind if I lose the change history.
From this post I was able to work this one out.
Turn off source control: Xcode -> Preferences -> Source Control -
Uncheck 'Enable source control'
Show hidden files in Terminal: "defaults write com.apple.finder AppleShowAllFiles -boolean TRUE; killall Finder"
Remove .svn folders from your project
Hide hidden files again in Terminal: "defaults write com.apple.finder AppleShowAllFiles -boolean FALSE; killall Finder"
Remove project from recent projects list: File -> Open Recent -> Clear Menu
Turn source control back on: Xcode -> Preferences -> Source Control -
Check 'Enable source control'
This effectively restarts version control using the current files as master.
Is there a way to temporarily hide or remove a file from Intellij? I used to work in c# and I remember there was some way in visual studio to temporarily remove a project from the build then add it back later. I am just trying to figure out what parts of code are necessary for certain features.
This is a perfect use case for git stash.
If you're not using a git repo, hit Ctrl+Shift+A and type "Create Git Repository", then hit enter to initialize git tracking on your current project.
Initially, you'll want to add your important files to git. Hit Alt+1 to navigate to the Project View, then select all the files.
In order to add a file to git, press Ctrl+Alt+A, you should see the filename turn from red to green. It is now being tracked.
Now you'll want to make your first commit. Hit Ctrl+K, and IDEA will guide you through this.
Finally, once everything's all checked in, you can start messing around a little. If you make a few changes, say delete a file, and want to temporarily revert to the last commit, hit Ctrl+Shift+A, then "Stash". Select "Stash changes", write a little message for yourself, and you'll immediately jump back to the last commit.
Now say you want to go back to those changes you stashed. Hit Ctrl+Shift+A again, type "Unstash" then select "Unstash changes". Find the stash, check "Pop stash" and hit Enter.
This is a pretty common workflow for temporarily saving, removing and reverting changes in Git. You can read more about git stash here, and version control on IntelliJ IDEA from Martin Balliauw.
In SVN we have one option to download code on a particular revision. This provides the flexibility to download code on old revision also for build.
Is there a option in RTC to download a code on particular revision?
Yes: once you have done a repo workspace on a stream (where that old version was baselined), you can select a component (in the components section of your workspace), and click on "Replace with".
You can then chose the baseline you want to see, and it will be downloaded if you have a local workspace or sandbox in place.
Simply don't "deliver" to the stream, or you would replace the most recent baseline by an old one.
For setting a file to an older version, it is a bit manual (as in this thread):
Right click on the file in the change set, and select "show history" (or if the file is in an editor, right click on the editor and select "Team -> Show_History). That will open the History view on the file, form which you can select the version you want.
SOLVED! 🚀
The only thing that worked for me was:
.
On your workspace's tab [Pending Changes] -> RightClick on the component that you want to get file(s) back -> [Show] -> [History]
RightClick on the "PackOfChanges" that has your wanted file(s) -> [Revert]
.
PS: It won't actually revert your actual project state to that day, and won't undo that "commit". The only thing that it does is showing on your workspace's tab [Pending Changes] all the diferences between that day and you actual code, and in every file(s) that you want back you:
"DoubleClick" the file that you want back that was showed by revert, and an Editor will appear with the diferences between you file's actual code and it self on that day, and you pass all the code from the right to the left.
After it's done, on your workspace's tab [Pending Changes], RightClick on the RevertPackage -> Remove
.
Have a nice day! 😄