XCode Git Head Detached - xcode

I'm new to programming so please dont bite my head off! I'm using Xcode with GitHub, but it's suddenly stopped working. Xcode is not showing the current branch on source control, it doesnt load remote repositories, and the git status is 'head detached'.
I've gone to the command line and done 'sudo git --version', and accepted the new license.
This project is for fun, but I've put a lot of work into it. I don't mind just losing the history of the project if need be, I'd just like to get GitHub's source control back to a working state. Any suggestions?

If you want to add commit with detached head to any branch you should use cherry-pick command
git checkout "branchname"
git cherry-pick "commitnumber"

Your screenshot is showing that you checked out a specific commit. The long hexadecimal number partially obscured by the red line in the screenshot is the commit number. When you check out a specific commit, you don't have a current branch so the git head is detached.
The fix is to check out a branch so you have a current branch again. Select a branch inside the Branches folder, the BrianTests branch in your screenshot, right-click, and choose Checkout.

Related

How to clear the branch names from TortoiseGit

In my git repo origin, i used to have the branches called "test" and "master". I removed the branch "test" from origin. And pushed a new branch "TEST". Notice that I basically removed the "test" with all small case and added a branch with all caps "TEST".
I ran "git fetch --prune" on my local machine. And then removed the branch test ("git branch -D test"). So, in my local i now have TEST and master branches. And i only see these 2 branches when i run "git branch" using git bash.
But, the issue i am seeing here is that, tortoise git is still showing the "test" branch that i already removed from my origin and local. Please help me in getting rid of the "test" branch from tortoise git as well. This is important for me, as there are other team members that use only tortoise git and not git bash and they see the same issue. So, i should atleast solve this issue for them.
Go to the directory of a git repo. Right click in the directory and you will see this menu.
Click on Git pull. You will see the following dialogue.
As you can see above, the Remote branch dropdown still displays "test"
if we click on git push from the first screenshot, this dialogue will appear.
And the remote dropdown in this case displays only "test" and not "TEST". Because of this, when people push this way, it is resulting in creation of a new branch called "test" in the origin, which is not intended.
I know we can manually type "TEST" for the remote branch before pushing. But, it would be nice if the "test" goes away which will prevent people from accidentally pushing to the wrong branch "test".
Selective removal: Mousehover an entry and then press shift+del.
Removing all settings: Go to TortoiseGit settings -> Saved Data and hit the appropriate clear button (cf. https://tortoisegit.org/docs/tortoisegit/tgit-dug-settings.html#tgit-dug-settings-saved-data)

xcode source control doesn't show current branch

I'm using the standard xcode source control (version 9.3)
I just reopened my project and when I go to the Source Control Navigator:
It shows a long hex string at the top instead of the current branch name
None of the branches have '(current)' next to them
I have tried cleaning the project and also closing and re-opening.
Source Control->Commit brings up the standard commit interface with the option to leave a comment.
When I click on the very top row (with blue icon) I can see the new commits but they don't show in any of the branches.
What am I doing wrong?
This worked for me:
I clicked on the row with the long hex name. This brought up the version history for the current version.
I right-clicked the most recent change in the change history.
I clicked 'Branch from...' and created a new branch from that point.
For those wondering how something like this could have happened, it is caused when you checkout a commit rather than checkout a branch. Even if you checkout a commit inside the branch that is "current" (even the most recent commit), this will cause the branch to no longer have the "current" written next to it. So when you are sure that this previous commit that you have now checked out is the commit you want to work with, then you must do what Derek posted to do which is to "Branch from..." to make a temporary branch and then merge this temporary branch into the branch that this previous commit originally came from. And then you can delete the temporary branch. It is somewhat of a pain, but a good reason why Xcode does this is so that you are well aware that you are on a previous commit and that you should really make sure this previous commit is what you want your current branch to be at.

How to remove an unused GIT branch in Xcode?

I can see how to create a branch, but I would like to remove one that I will never use. There doesn't seem to be such functionality in Xcode, so I tried in terminal doing
git branch -d BugFixes
but no luck.
You can delete git branches in Xcode. Choose Source Control > WorkingCopy > Configure WorkingCopy, where WorkingCopy is the name of your working copy, which is usually the name of your project. A sheet opens. Click the Branches button at the top of the sheet. Select a branch and click the minus button at the bottom to remove the branch. Note that Xcode does not let you remove the current branch.
Xcode 9 Update
Apple moved the user interface for branches to the source control navigator in Xcode 9.
To delete a branch, select it, right-click, and choose Delete. You cannot delete the current branch.
please try:
for local: git branch -D BugFixes
for remote: git push origin :BugFixes

How do I revert back to earlier commit using source tree

I have a project stored on my Mac and created a repository for from that location to my project. I am able to commit using source tree but now I would like to revert back to an earlier commit so all my files in folder update? I'm not sure how i do this?
Temporary Revert Back
If you want to temporarily go back to this commit, then come back to where you are.
Right click on the commit you want to revert to and click on "checkout".
Permanent Revert Back
This will add commits to revert all your work since this commit
Right click on the commit you want to revert to and click on "Reset <> to this commit".
I think in above discussion #dominones and #Giraldi maybe misunderstand each other,
#Giraldi maybe want to delete those unwanted commits permanently in the GIT, and make the git go back to a certain history commit, from there he could start all over again, like you want to be fresh from the beginning of somewhere.
while #dmonones is showing just how to revert back to a status of your code in a history, discarding some code changes you did, which will mostly end up with a new commit aiming to remove a unwanted/mistaken change,
without changing the git history.
To discard an already committed commit in git history, you need to use hard reset and push with force.

How to ignore uncommited change in Github gui for MAC?

I am using Github GUI for Mac.
Now I've some changes in my local repository, but I want to ignore them and pull latest remote repository.
I tried Repository/Pull, but got Git Error.
"•error: Your local changes to the following files would be overwritten by merge:
Classes/xxx.m
Please, commit your changes or stash them before you can merge."
I tried Repository/Synchronize, but got following error.
"Sync Failed. Please commit all your changes before syncing."
Any idea?
Place a checkmark near each of the changed files, then go to the Repository menu and click Discard Changes to Selected Files.
If you mean using MAC GUI only, check and right click the changed files then select the discard the changes.
if you want to remove your uncommitted changes, just do a checkout on those files again.
Stash is super easy too though, and it keeps your changes in a local 'bucket' or stash :)
For those on Github for Windows, it is not obvious where Discard All Changes is, so I wanted to share this:
Select Files by using check mark next to names.
Right click on Collapse All/ Expand All button with two arrows. (This button is on right side of Files to Commit box, and under Sync and Gear icons.) This is where Discard All Changes is >hidden<.
Sorry but too low level to add comment to #Leo wangs or #aspiringwebdev chain above. You gotta start somewhere...

Resources