Remove some commits in GIT - c#

I am new to Git, although I just managed to change file in my previous commit.
First commit in redbox let's call it R1 is the one with commited password. I made it accidentally, so I wanted to make change - just change the file where that password was. I managed to do it successfully, not from the first time.
So I the commits the "path" to my head - last commit is the green box. These commits are same as the red one, but without the password.
So everything is as I wanted it to be, but I want to remove the 3 commits that are in a red box, cause password is still there.
Can you tell me how to do it?
I understand that this might be a duplicate, but I have a picture so maybe it will help to understand better.

It looks like what you may be looking for is $ git rebase -i which will bring up the interactive mode for rebasing your commits. In interactive mode you can edit, squash, discard previous commits. This is a previous discussion about using interactive rebasing. source
This should be enough to help you clear away the previous commits that contain the details that shouldn't be public.
In the future you can create a .gitignore file that will tell git to ignore certain files, which helps greatly with privacy and security issues. You can find more about .gitignore files here.
In the future if this occurs you can easily erase a commit by using git reset --hard HEAD~1 which will bring you back to the commit before the head.
You can use git log at any time to find a specific id of a commit that you want to jump back to with git reset --hard <sha1-commit-id>, but be advised this will delete the changes at your local working level.

Related

Can't get latest updates

I using Git with Bitbucket - every time when I have this issues I deleted my files from local PC and copied it from bitbucket. I think it isn't good idea do it every time.
What happened: usually for correct work I did next step - update my branch for last version and after that I commited my updates in my Branch. Before I got this problem - I didn't get latest updatets, because someone did several changes in my Branch without me. As result I tried to commit changes from my PC and couldn't do it.
Now I wanna delete outgoing commit and try to get update, how can I do it? (I tried do: click on my commit->Reset->Reset and delete changes (nothing happens)/ and I tried: action-> view history->find my commit and click on a reset ->Delete changes(nothing happens)).How can i delete outgoing commit?

programmatically find commits in one branch but not the other

Given two branches, feature/SomeWork and develop
How do I find the list of commits in feature/SomeWork that have not yet been merged to develop using libgit2sharp?
I am currently programmatically walking through each of the commits and checking to make sure they are present in the target branch
I am hoping there is a more straightforward and faster way of doing it
Note: I need to do this programmatically within my application using libgit2sharp, I know the way to do this via command line, but would prefer to avoid shelling out to process and reading output, etc. if possible, thank you
I think you're looking for the git cherry command:
git cherry -v develop feature/SomeWork
That command should list all the commits in feature/SomeWork that are not in develop.
This command should give you what is needed.
git log feature/SomeWork ^^develop --no-merges
Please note ^^ , one of ^ is used as escape character on windows.

What is R60, R72, and MINE file?

I was building a DataAccessLayer using C# in VS 2012, and in my project, there are three files which I don't know how to deal with.
DataAccessLayer.csproj.mine
DataAccessLayer.csproj.r60
DataAccessLayer.csproj.r72
What are they? How should I deal with them?
They are files created from your repository that the code is saved in. You did an update and when you try to commit your files you will get a commit failed probably. When you diff the files, it will use the .mine .r60 .r72 files to bring up the differences between each revision (.r60, r72) and your file (.mine) and allow you to do something like Keep all changes in mine.
In order to get rid of the commit failed error messages, find the original file, update it with the correct changes, and when finished right click it and Mark as resolved and commit. This will get rid of those files.
Those files are related to version control (.mine is your file, .rX come from revision number X). You should try to merge them using your version controlling tool if you have one. If you don't have one and got those files by copying a project, you can possibly delete the .r files and rename DataAccessLayer.csproj.mine in DataAccessLayer.csproj (unless you already have DataAccessLayer.csproj - just keep it and delete the other then). Edit: And if it causes problems, try merging them manually (using a text editor for example) before keeping the final file.

anksvn checkin file

I am using the most recent version of anksvn for a visual studio 2008 project file. I now
want to check this code into anksvn, but I am having a problem.
The situtation is, I checked in the most current version of code into anksvn. That is fine.
However I have another version of this code that I did not check out from subversion initially. This other copy of the code was for a 'demo' only. However now this code needs to become the production code. Thus I am trying to determine how to check this code into anksvn.
What I know I can do is to 'remove' the most curent code folder that is in anksvn. I could then place this project folder into that location. since the origianl 'demo' code also includes the current production code.
However I am trying to see if there is a better method to accomplish this goal. Could I possibly use the branch/switch option?
Is the demo code checked out of Subversion at all? I know you didn't check it out, but was it checked out? If it was, you could commit this code back into Subversion, then update your working directory.
It his code has nothing to do with Subversion, you will have to take a more complex route: You will have to copy the changes manually to your code.
Since you're using Windows, you should take a look at Beyond Compare, This is commercial code, but you can download a limited time demo for free -- more than enough time to handle your situation. I use Beyond Compare all the time to compare two different directories or Java jar files or zip archives, etc. It not only can quickly show you the differences, but makes it each to copy those differences from one to the other.
I have no relationship with Scooter software, the makers of Beyond Compare except as a customer.

Visual SVN - How to maintain separate user settings and publish settings?

For a new MVC web development project, I'm collaborating with a couple of other developers and we want to use Visual SVN to manage source control.
Following the "Getting Started" instructions at the VisualSVN website (http://www.visualsvn.com/visualsvn/getting-started/) seems to to commit everything within the Solution folder including all the settings file (.suo, user, .Publish.Xml)
However, we want to maintain separate Publish Settings within Visual Studio as we publish to our local machines for testing.
Is that possible?
P.S. Shouldn't VisualSVN Client automatically ignore the .suo and .user files?
it doesn't you'll need to either
add them to the ignore on commit lists - you can do this while committing but its a per user setting
remove them from svn - delete them from svn using tortoise as visual svn cant see them (take copies first, as I think this will actually delete them), commit the delete. Put them back into the folder and commit again, svn will show up these files as uncommited, right click on them and select ignore in the commit window, and commit them, this will apply to everyone. Its easier to not commit them in the first place :)
I use SVN as my source control as well. I also use VisualSVN (but only server side). The main thing I would suggest is to use VisualSVN to host your repositories, but use something else to commit/update/checkout your repositories to your local machine.
I would suggest TortoiseSVN for this. Use TortoiseSVN to control your workflow on local machines. You can then use it to simply right-click/ignore your *.suo files. Or any other files/folders you wish to keep out of the repository!
It may take a bit of research to get it setup. But this is what I use on an every day basis, and it is very user friendly.
I've never used VisualSVN, but I would be surprised...no shocked if what you said was true.
Does VisualSVN really by default automatically add and commit user files? You'd think a solution that's built for VisualStudio would simply know better. I would call the company and verify this.
If VisualStudio does commit local user files, I would recommend that you use AnkhSVN instead.
Not only does AnkhSVN know better than to commit user files, it's also open source and you can save yourself the $49 per user you need for VisualSVN. And, it's not just the $50 you're paying per user that you pay with VisualSVN either. It's also the fact that you have another license you need to track while users come in and leave the project. Who do you think is going to get that fun job?
However, if you must use VisualSVN, and VisualSVN does commit user local files by default, You need to get my kitchen sink pre-commit hook. One of the things it does is allow you to completely ban the addition of files such as Visual Studio's *.csuser` files and the other types of VisualStudio detritus.
Of course, you should let developers know how they can set global-ignores and autoproperties in Subversion. This will prevent them from accidentally adding them. But, there's no way you can configure that globally, or to prevent someone from purposefully adding them. Only my pre-commit hook can keep them out of your repository. After a few failed commits because your developers tried to add in these private user files, your developers will quickly fall into line and set up their global-ignores.

Categories