In short, I use git recently. I made a new xamarin.forms project and constantly committed it, but when I was very naughty about the project, I decided to roll back to the previous version, but, on the march, in a very flawed way. I downloaded the zip file from my project's githaba, opened it and continued to write the project, but when it’s time to commit, nothing happens, the commit button does not light up. Maybe you can fix it?

  • one
    Я скачал зип файл с гитхаба that is, your code is not in any repository, what and where are you going to commit? - tym32167
  • 2
    If you are working with github, then you probably need to clone repositories, and not download zip archive - tym32167
  • one
    Dude, where are you nakosyachil - make a rollback to an adequate version, and where you downloaded and wrote the code, copy and paste in the rollback project. - Aqua
  • four
    Clone the repository into a separate folder, then on top of this, copy your changes from the original folder and commit - tym32167
  • 2
    First, make a copy of the directory in which you did something. It contains the archive of the project + your changes. This will help you not to lose anything. Secondly, clone the project into any folder, then fill the contents from your copy. After that you can commit. Well, if you have rights to commit to the repository. - AK

1 answer 1

First, make a copy of the directory in which you did something. It contains the archive of the project + your changes. This will help you not to lose anything.

You need to understand that you can have multiple copies of the repository on one computer and each of them can have different states. We want to keep your original work without a change - in order not to break anything in it: we will work with another copy, the right one.

Secondly, clone the project into any folder. You made a mistake by downloading the file with the archive of the repository, make this time correctly: you need to use the git clone command.

Read more in the guides to git or look at these two questions ( one , two ) on so.

To work from Visual studio you can do the following:

  1. Open Team Explorer (in menu View -> Team Explorer)
  2. Click on the house icon
  3. Select item Clone

enter image description here

enter image description here

You need to learn how to perform this operation, so practice well before proceeding to the next step!

Then you can work with your new, correct clone of the repository. The key question here will be: do you have the right to make commits to a project that you yourself took on a computer or not.

If there is access (this is the easiest option), then you need to change the files of your copy and issue them with a commit. We take steps:

  1. We take the original project that we downloaded and upload directly to the folder of the correctly cloned repository. Important: check that in your project where you made changes there is no hidden folder .git ! In principle, it should not be there, but check better, because it is in this folder that all the information about the cloned repository, which is needed for git utilities, is located.
  2. Give the command git add -A
  3. Give the command git commit -m "my commit description"

Or we do it through the visual studio interface, two teams can be done in one fell swoop: they opened the team explorer (view menu -> team explorer), entered the commit text and clicked the commit all button:

enter image description here

If there is no access, then you need to clarify with the owner of the repository how to make changes correctly. Usually on github it looks like this:

  • You make yourself a repository fork (there was a project https://github.com/someone/project your login mylogin you make a fork yourself project https://github.com/mylogin/project and you own it)
  • In the fork do a separate branch, pour changes into it
  • Submit a pull request to the source repository that the host of the source repository will accept (possibly forcing you to make any clarifications / changes)

This option is much more difficult with unaccustomed, so get ready for the fact that you may not get everything right at once or that there will be questions.