Undo in vs code after closing and open again vs code - visual-studio-code

How to undo vs code changes after closing the vs code and open again
I tried many time control z and control y to make change but it stucked.

What you are asking for is not possible.
However, there is another way to achieve the same result with some preparation: put your code in a git repository, and before making changes commit your work. Then if you find you want to roll back changes to a previous commit point, just use git checkout.

Related

Source control not working in Visual Studio Code

When using source control every change showes up as they should, but when I try to commit, push, pull etc nothing happens. This happens with both old and new projects. I have tried to reinstall the app without any luck. How can I fix this? Is there a way to "reset" source control?

Regarding GitHub and version control

Recently, we have started a group project and decided to use GitHub to share the code among ourselves.
For example, if I created a login page and my friend created a home page, how can I get it on my local machine.
I mean, whenever a change is made to the repo, do we need to download it all again?
The beauty of GitHub is that you can always go back whenever you feel like.
Whenever a changed is made by any of the teammate, it's a really good practice that you push that change. Even when it's a small one. After you've pushed your changes, your teammates would need to pull that change.
The best sequence for this is;
- git commit
- git pull
- git push
You'll have to pull the changes first as it would help you avoid getting merge conflicts. If you get any merge conflicts on any line, or any function, you'll resolve that conflict and follow the same sequence once again.
So, to conclude, GitHub is so easy to use and you won't have to necessary 'Download' all the changes once again. I would recommend you to setup via Visual Studio 2019 so that it becomes easier for you to just "pull" the changes whenever a new change has been made.

Clicked reset branch to current commit and lost all my work, what the heck have I done?

I am brand new to Source Tree and have no idea what Im doing but I hope I didn't just lose my work.
I clicked a button that says reset branch to current commit, and chose the "Mixed" Option. I then pushed my files. But after going back into UE4 (a program Im tracking) I noticed that my files have gone back a really long time. I can see all the files I have in the "Working Copy" section of source tree, but all of them say "Missing" and am too afraid of doing anything in fear of losing it all. I need help on what button to press to undo my changes (CTRL Z DOESNT WORK :( )
Here are some pictures of where I am.
If it says "Working Copy" and I am able to click "Open Before" I assume the files still exist, I hope.
If I can, how do I get my Files back to the way they were before I messed up.
If you committed the changes before using the reset branch, the changes are not lost.
I'll explain this using command line commands, but I guess there are advanced GUIs that can achieve the same thing.
Open a command line interface of your choosing that has access to git commands, then navigate to the project folder
$ cd /path/to/project/root
Next, check the git reflog
$ git reflog
874333c HEAD#{0}: reset: moving to 874333c
5dc3401 HEAD#{1}: commit: committed something awesome
4ef6395 HEAD#{2}: commit: fixed bug related to ballistics computation
d5cb3b3 HEAD#{3}: commit: added ballistics computation
What you want to do now is to reset your branch again, but this time to the state it was in before (ie. 5dc3401) you did a reset to the current state it's in
$ git reset 5dc3401

Reverting one file in GitKraken

It is possible in GitKraken to revert changes of a single file to an earlier commit instead of reverting an entire commit?
Answer
A revert in the git-sense of it can only be performed on a commit. It introduces a new commit that exactly negates the reverted commits' changes. See here. GitKraken supports this: right click on a commit, Revert <branch> to this commit.
What you want to accomplish, however, can be done via git checkout. I do not think GitKraken supports this funtionality for a single file yet. You can, however, use the command line.
Reset single file via command line
git checkout <commit> <file>
Check out a previous version of a file. This turns the <file> that
resides in the working directory into an exact copy of the one from
<commit> and adds it to the staging area.
Documentation can be found here.
git checkout HEAD~1 <filename> will thus reset a single file to the commit before the current HEAD.
You can accomplish this in the GitKraken UI, but it's a little roundabout:
Revert the most recent commit(s) back to where the file was deleted, but when GitKraken asks if you want to immediately commit the reversion, click no.
Unstage all changes
Stage only the add for the file you're trying to restore
Right click in Unstaged, and Discard all
This should leave you with only an add for the one file you wanted to restore. Commit that, and now you've got your one file back.
Note that this can work across numerous commits, not just one... but since it's going to have to roll back everything from all of those commits, and then discard all of the rollbacks (except one) it can be quite slow if involves massive changes. In situations like this, it is probably better to use the git CI as suggested in kowsky's answer.
Although it doesn't strictly involves using git commands, GitKraken offers the possibility to visualize the content of any project file at any given commit.
When acting on a single file, it might be much easier to copy/paste the targeted commit file's content than using complicated git commands that might very well end up messing your whole project's commit history.
To achieve this, simply:
Open your git project in GitKraken
Click on the desired commit in the commit history line
In the right panel, check the View all files checkbox
Locate the desired project file and click on it
The file content will be displayed in the main panel
You can now copy/paste the content
Simple and efficient when you only need to revert a very limited number of files...
GitKraken 7.3.0 (probably older versions too) does allow for effectively running git checkout on a single file in the UI: Right click on the file under "unstaged files" and select "discard changes". Works on folders as well.
(This answer was previously a comment to the accepted answer)
You can make an UNDO to the last commit edit it and after that make a Force push to overwrite that. Works very well
Hope GitKraken can do this, as "TortoiseGit" does.

Difficulty in switching between various versions of code and commiting changes using SVN in MATLAB

I am using SVN for version control in MATLAB 2014b. I have edited my file 'main.m' three times and commited changes to SVN repository. Thus there are three versions of my file, say commmit1, commmit2 and commmit3. Now, I wanted to revert my file from commit3 to commit2, make some changes in commit2 and finally commit this edited version to create commit4. I have successfully reverted from commit3 to commit2 and made some changes in it. But, now I am unable to commit changes made to commit2. It shows error commit failed,'main.m' is out of date. Please help me in sorting out the issue.
If you are using TortoiseSVN as client the follow this procedure.
Select the file and right click and then click on TortoiseSVN
Proess the show log option from drop down menu andyou will see a window
select the specific checkin which you want to revert to.
Press right click and then press "Revert to this revision"