Steps:
Navigate with a browser to the github.com/user_name/repo_name/commits page
To the right of the desired repo click the far right <> button
with the tooltip "Browse the repository at this point in the
history."
Note the page just navigated has a URL like
github.com/user_name/repo_name/tree/Some_UID
Click on the green "Code" button in the repo, then click "Open
in Visual Studio".
After launching the MS VS Web Protocol Handler Selector from the
popup dialog (with the "always allow Github to ..." checkbox), VS launches showing the Team Explorer dialog, with the URL of just
the base repo (github.com/user_name/repo_name) in the remote URL
box.
Attempt to replace the default URL with the desired commit
(github.com/user_name/repo_name/tree/Some_UID) in the box and then
click the Clone button.
The following message is generated at the top of the dialog:
Git failed with a fatal error.
repository 'https//github.com/user_name/repo_name/tree/Some_UID/' not found
An empty directory with the name Some_UID is also created in the base repository directory.
Is there another way, preferably from the VS/Github GUI, of opening an older commit in Visual Studio?
Edit: The obvious solution is to open the Git history window in VS and right click on an old commit in order to revert to it. Given that Git Revert creates a new commit, which adds to the Git history chain,- the idea here was, in fact, to somehow open a new solution (in a different directory) with the old commit for quick testing, and delete it when finished. An idea which might seem feasible so long as the new (temporary) solution had no Git, or at least no bindings to Git that would point to the original solution.
Clone the origin project.
Find the commit id, then reset to the id locally.
git reset --hard xxxxCommitIDxxxx
Related
We use TFS for maintenance of some software that is at their end of life in the company.
So in Visual Studio 2019 we - me and my colleagues - struggle to add an HTTPS URL for the TFS server.
It seems to fall back to HTTP, but our TFS does not allow HTTP.
What we tried so far:
remove all TFS connections (we leave the Azure Git connections we have)
even sometimes closed this single open Visual Studio process instance
add the fresh TFS connection as HTTPS URL: e. g.
https://<product>tfs.<ourCompany>.<country>/tfs
it is added as connection with HTTPS
but as soon as it is mapped to an existing local repository, the connection falls back from https to http and the URL is again:
http://<product>tfs.<ourCompany>.<country>/tfs
It always falls back to HTTP.
PS: On the old notebooks - notebooks were renewed in the R&D departement this year - a colleague did have:
https://<ip>:8080/tfs
instead, my Visual Studio 2019 at that time on the old notebook proposed me to change it to
https://<product>tfs.<ourCompany>.<country>/tfs
I did it and it worked in the old notebook! I even did commit/push (in Git terms, what are the TFS terms?) the changed *.csproj to the repository.
The other colleague with the IP URL got these project files and it worked for him too.
What could it be?
I did not work with TFS since 8 years, and then very shortly, so is it some simple thing?
I tried this afternoon another version and finally it worked with these steps:
Open VS 2019 (it is the only open instance now, no solution opened)
open "Team Explorer"
"Manage connections..."
Remove all connections tfs.. (but leave local git repos and .visualstudio.com for the remote git repos)
Close VS 2019
(then I opened VPN, because I am in home office, shoudln't have any influence)
Open VS 2019 (without solution)
open "Team Explorer"
clicked on green plug icon
"Manage connections..."
In the opened "Connect to a Project" dialog:
"Add Azure Devops Server"
In text edit called "Enter server URL" entered:
https://tfs../tfs
button "Add"
in the tree below is a new node called tfs..
browse to the proper branch/project (leaf symbol a bit like "Covid-19" virus)
button "Connect"
Now it takes it properly as https-URL (display of URL in "Team Explorer - Home")
Go to "Source Control Explorer"
Left in the tree a customer specific branch chosen
"Not mapped" link clicked
In dialog "Map" "Server folder:" was set now to "$/"
and added in "Local folder:" a new empty folder (in reality it was not empty, an existing repo, but in the wrong folder level)
button "Map"
Dialog "Map\r\n\r\nNewly mapped items will not be downloaded until you execute a get. Do you want to get $/ now?"
"Yes" button clicked (was in local language)
"Get Progress" progress dialog appears for a while
after it ended a new dialog appeared:
Then there were pending changes:
URLs in sln and only few csproj files (of a lot more)
commited and pushed these changes
Now it seems to work - hurray
Check Things to do after you rename the URL of your account.
You also need to update Git remotes:
In the web user interface, click the Clone button and copy the new Git URL.
Open a command prompt window. Change the directory to the Git repository.
Update the remote URL. Assuming that the remote is named "origin," the command would be git remote set-url origin <url_copied_from_web>.
When I start a new project with GitHub I always struggle with the same issue. When I create a GitHub project it's already prepopulated with some files (.gitignore, LICENSE, README.md) and hence with an initial commit. I explicitly choose to add these items so I don't have to care about writing them myself.
On the other side, when I start a new Xcode project it works in a very similar way: Xcode creates an initial commit with some files. So when I'm trying to pull my GitHub repo I always have to deal with Git refusing to merge unrelated histories problem.
Is there a correct workflow for this?
Here is the easy way to do this, assuming that you are using a recent Xcode, e.g. 11.2...
create new repository in GitHub, checking .gitignore file and README.md file options
copy repository URL from browser's address field
create new project in Xcode, checking local git repository option
right click Remotes in project's source control navigator to add remote, using URL copied earlier, suffixed with .git
select Fetch and Refresh Status from Source Control menu
select Pull from Source Control menu, from origin/master remote (.gitignore and README.md files are now in your local repository... if in Finder, use Command Shift . to toggle hidden files display)
select Push from Source Control menu, to origin/master remote (Xcode project files are now in your GitHub repository)
Voila! You have set up a new project in Xcode and GitHub in less than a minute.
Just came across the same issue. It actually works on Xcode 11, if you follow these steps:
Create the repository on GitHub including initial branches, License, Readme.md etc.
At the Welcome screen of Xcode choose "Clone an existing project"
Clone your repository into the desired directory (usually a subdirectory of XCodeWorkspaces)
Close Xcode and reopen to get back to the Welcome Screen (that's the trick)
This time choose "Create a new Xcode project"
Place the project into the cloned directory. Xcode automatically picks up, that this directory is already under Git control.
You'll see that the initial files are marked with A and M in the Xcode project navigator
In the menu "Source Control" choose "Commit". You should see all files created by Xcode. Make sure to activate on "Push to remote:" and choose the right branch. Press Commit
If nobody committed or changed on GitHub between step 1 and step 7, it'll work. Check on GitHub.
I noted that some files in my solution explorer are not in source control as they do not have a padlock icon. I tried to rebind the solution as suggested here but I do not have a Source Control menu item under file.
It seems you are using Git as your source control. There is no Source Control menu item under File for Git. It’s a normal phenomenon. This menu item is only for TFVC.
No matter your folder(Solution items) are adding in source control or not, there is no padlock icon in front of it. It’s by designed. Normally, if you can see it in Solution Explorer, means it has been added in source control. You can double check it through your Web Portal(Code→Git→Your solution)
If you can’t see it , you want to add it in source control. Right click your solution in Solution Explorer, select source control, select commit, then commit and push. Or use git command, $ git add . /$ git commit -m "First commit"/ $ git push origin master
You can enable/disable the plugin selection from Tools->Options if you are using TFVC as your source control although I suspect Patrick is right with his assumption on Git.
I was indeed using Git but even right-clicking on my solution did not provide me with the source control option (as #Patrick suggested). Eventually I noted that in Team explorer > Changes there was a section containing Untracked Files. I clicked Add all, and these files started being tracked, thus solving my problem.
I have created a new project and checked the "create a local git repository" option. I opened the organizer to check that there is a repository for my project and it was there. I made some changes on some files, and noticed the source control specific letters "A" .. "M" beside them, but when I choose: File-> Source Control -> Commit, I get the following message from XCode 4.2:
the operation could not be performed because no valid working copies were found
Please verify that your files are under source control and try again
However, I opened the organizer again, and noticed that the repository of my project includes three icons on the left bar: Branches, Remotes and a folder with the same name as of the project. I chose the last one (the folder) and pressed the Commit button on the bottom bar of the organizer. The commit sheet opened and I performed the commit successfully. Now, when I close the organizer, and edit some files in my project, I do not see the source control specific letters "M" ... "A" ... beside each modified file.
My problem is about two points:
1) Why can't I commit from File->Source Control->Commit menu option
2) When I commit from the repository itself, and go back to the project and edit some files, why do not I see source control letters beside modified files?]
For what it's worth (and as #Jahelia's comment mentions), this seems to be a bug in XCode 4.2 when it first engages with git. The workaround seems to be to at least close Xcode and reopen. (If that doesn't work, try opening and closing the organizer.)
I encountered this myself today when trying out Git with Xcode for the first time. I created two demo projects with the "create a local git repository" option and they had the same problem. I was able to commit from the organizer window, but the main Xcode file view didn't seem to recognize git at all.
After quitting and restarting, I created a third demo with the git option, and the main window recognized the changes (after building) right off the bat - i.e showed the "M" beside a modified file.
I've experienced and recovered from this.
I can't tell you what causes it but, notably, in the "Repositories" view in my Organiser, I had TWO similarly-named repositories. What differed about them was the case of one of the paths.
One was "~/Work/Code/Bumhole" and the other "~/work/Code/Bumhole".
I caused the problem by XCode crashing during a commit to the repository (of many changes).
I fixed the problem by
closing the offending project
closing Xcode
rebooting
reopening Xcode
(close the project if its open)
open the Organiser view
Select the "bad" repository and delete it with backspace
Navigate the remaining "good" repository until you see the .xcodeproj file
Double click the .xcodeproj file to open the project
I expect this list is a superset of the steps needed to fix the problem, but this worked for me.
If your project is in /Developer/.... move it elsewhere and reopen the project. This may resolve your problem.
There seems to be a problem under Xcode 4.2 with projects in /Developer/... and git integration (you get the error "The operation could not be performed because no valid working copies were found. Please verify that your files are under source control and try again")
This bug still exists in Xcode 4.6.3 and when using Subversion.
I know this has already been answered but this worked for me:
Open terminal
cd yourprojectdirectory
git config --global user.email "youremail#email.com"
git config --global user.name "username"
I have configured Xcode to use Subversion (hosted on a remote webserver - Beanstalk.com).
In Xcode menu under SCM, I want to know the difference between two options
1. "Refresh Entire Project ..." and
2. "Update Entire Project ..."
Please help.
Thanks
Dev.
Open the SCM Results window from the SCM menu item, click on the little 'text' button on the left-hand-side (might be at the bottom of the window to start with?), expand it so you can see a little more, and then run refresh and update to see what commands Xcode passes to SVN.
Sorry, can't speak for SVN right now, but for CVS it did this for me:
I believe Refresh will check the repository if there is a newer, updated version of any files within your project that may have been committed by another developer since your last checkout.
Opening your SCM Results view will show you in the 'Update' column what files have been updated since your last checkout with an 'M'.
If you select Update, you will actually pull down those files and update your current project while Refresh will just check the files and list them in the SCM results window without downloading and overwriting your file.