I had a project I'd been working on and I wanted to start a new branch so that I could make edits without ruining the original
I went to source control, new branch.. etc. I ended up discarding all changes in the new branch but when I returned to the master branch, everything was gone. My files are still in the folder in finder but they arent showing up in xcode. My storyboard files when opened separately are blank.
Is there anyway to fix this?
If your changes are saved in remote repository, then you can pull all your changes for that branch from remote repository.
on master branch run this command
git pull origin master
Related
I committed changes to a local git repository today in Xcode so that I could go back to an older version. The newly committed changes from today are not showing up in the source control tab within Xcode; however, when I navigate to the .git folder in Finder, I can see the commit message in the COMMIT_EDITMSG file. This leads me to believe the commit did work, but for some reason Xcode isn't recognizing it. Is there any way to manually recover those committed changes from Finder if Xcode won't recognize them?
When using TFS, it is simple to exclude changes in Visual studio just by right clicking.
How can I do the same in VSTS which is now Azure devops? I have a repository with multiple solutions and i only want selected changes in a particular solution to be committed and pushed to the server. But how to perform this operation?
When using Git, you can stage changes you want to commit. If you have staged changes, all other unstaged changes will not be part of the commit. Staging a file is simply preparing it to be committed.
When you do not stage changes in Visual Studio, by default all changes are committed. See the left side of the image below: the button says 'Commit all'. The changes are all grouped together. If you commit like this, all changes would be committed.
In the right part of the image, you can see there are Changes, and Staged Changes. The commit button's text has changed to 'Commit Staged'. If you commit like this, the Notifications.cs file would be part of the commit, the News.cs would not be part of the commit.
You can (un)stage changes in Visual Studio by right clicking them and selecting (un)stage. You can also selecting the files to (un)stage and using the plus sign at the top right of the Changes to stage, and the minus sign at the top og the Staged Changes to unstage.
In short: by staging changes, you can determine which changes are included in the commit you're about to create. Here's some more information on Git Basics, the below information about staging can be found at the bottom of that article.
The staging area is a file, generally contained in your Git directory, that stores information about what will go into your next commit. Its technical name in Git parlance is the “index”, but the phrase “staging area” works just as well.
The basic Git workflow goes something like this:
You modify files in your working tree.
You selectively stage just those changes you want to be part of your next commit, which adds only those changes to the staging area.
You do a commit, which takes the files as they are in the staging area and stores that snapshot permanently to your Git directory.
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.
We use TFS for our source control system, but need to work with a contractor. We've set up a GitHub repo and I've been using git-tfs to move changes between the two. I'm not very familiar with git, and have managed to get myself into some trouble.
The git repo was in sync with the TFS repo. The contractor pushed a few commits to GitHub. After that, I checked in a few changes to TFS, then performed a git-tfs pull followed by syncing with GitHub (through the GitHub for Window application).
The changes I recently checked into TFS are in the GitHub repo. The changes from the contractor are in the GitHub repo and in my local repo, and I'm trying to get them into TFS. When I run git-tfs checkintool, I get:
Working with tfs remote: default
Basing from parent 'default:11102', use -i to override
Nothing to checkin!
If I run git-tfs rcheckin, I get the following. This shows the changes I'm trying to get into TFS, but notice the message at the bottom The item $/RDi/Software/System/SZ-Working3/EmbeddedGui is not a branch of $/RDi/Software/System/SZ-Working3/EmbeddedGui.. I think this is the problem, but I'm not sure how to rectify it.
Working with tfs remote: default
Basing from parent 'default:11102', use -i to override
Fetching changes from TFS to minimize possibility of late conflict...
Working on the merge commit: d2a85cd7b88715cabc6ed6cf5b9b7b5fc60359e0
Starting checkin of d2a85cd7 'Merge commit 'd36d26a6c6af5c1e89cf4dc7b2634964827b3ded'
Updated port screen PSD files. Should have what contractor needs regarding the animated arrows.
Replace language PSD files with new ones - the new ones contain the button pressed state for the OK/Cancel buttons.
Remove test file.
swiping removed from language page
Worked on issue 25: RemoteLib locks up when network settings update.
yes/no button added on language page'
edit .git\~w\QtJson/JObject.h
edit .git\~w\qml.qrc
add rsrc/images/480x272/common/no-small.png
add rsrc/images/480x272/common/yes-small.png
add rsrc/images/800x480/common/no-small.png
add rsrc/images/800x480/common/yes-small.png
edit .git\~w\rsrc/qml/pages/MetricsPage.qml
edit .git\~w\rsrc/qml/pages/RegionalSettingsEditorPage.qml
The item $/RDi/Software/System/SZ-Working3/EmbeddedGui is not a branch of $/RDi/Software/System/SZ-Working3/EmbeddedGui.
The item $/RDi/Software/System/SZ-Working3/EmbeddedGui is not a branch of $/RDi/Software/System/SZ-Working3/EmbeddedGui.
When trying to setup the source control feature in Xcode in an existing project, I changed branch to the one situated at github, but as I did that all my code disappeared an now I am not able to open the project as it says cannot be opened because it is missing its project.pbxproj file. Can I somehow switch back to my local master branch and recover my project? :(
For me, neither the issue or solution had anything to do with a source control repository. Somehow the project folder permissions got screwed up. To fix it, I opened the folder containing the project, did "Get Info..", clicked on the lock to unlock it, clicked on the gear icon near the bottom of the pane, and selected "Apply to enclosed items..." This reset the permissions throughout the project folder, after which I could open the project.
What has happened here is that you checked out a branch that does not contain the xcode project (or at least not all its components).
yes, you can switch back to the master branch and have everything that is in master including the project (assuming it was committed prior to master)
considering your problem you may need to use terminal to checkout master. in that case open terminal and cd to the project directory and do git checkout master