Rearrange Git branches in Xcode? - xcode

I use Xcode's built-in Git/Hub integration for day-to-day use. In one project I made a branch, and when you use Commit... Push to remote", you are asked to select which branch to push to.
The problem is that the branch, which is used only rarely, is the first entry in the push pop-up. I often check into the wrong branch during a push simply because I don't notice it is the default selection.
Is there any way to sort these entries, or temporarily mark one so it does not appear or is greyed out? You cannot drag them in the source control pane on the left and there do not appear to be any options anywhere.

Related

Switch / Checkout from Git Synchronization dialog

I need to do a lot of switching between branches from a remote repository to inspect code, perform code reviews, contribute to other developers' work and such. I'm not a command line fan so I use TortoiseGit almost exclusively. I also prefer TG over Git clients in various IDEs because I find it really shines when you run into more complex operations like non-trivial three-way merges.
I noticed I find myself clicking A LOT, though. To switch to another branch consists of: Revert or stash any current local changes, fetch (to get the latest remote branches), switch/checkout. So I started looking into the "Git Synchronization" dialog, hoping that I could perform all those operations from within one dialog with a few less clicks, dialogs and OKs.
However, I simply cannot find the switch (or checkout) functionality in that dialog. Is that simply missing, or is there some other Git operation or combination of operations that accomplishes the same?
Quick solution
You can simply select a different branch from Local Branch dropdown in Git Sync dialog. When you subsequently invoke Pull, TortoiseGit will force the checkout automatically:
For other operations (Fetch, Push) switching to a branch is not necessary. However be cautious with the Commit and Show log buttons as they will always apply to the current branch (not the branch selected in Local Branch dropdown) and no checkout will be forced.
Solution using Switch/Checkout dialog
If you need to use full Switch/Checkout dialog TortoiseGit dialog, you can use Browse references dialog which you can invoke from Git Sync dialog by clicking on the ellipsis button next to the Local Branch dropdown.
In the Browse references dialog there is a list of available branches. You should right click the desired branch you want to checkout and select Switch/Checkout to this from context menu. Switch/Checkout dialog will pop up. After completing the checkout, return to the Browse references dialog where the desired branch is selected and click OK. Now the desired branch is checked out and also selected as a Local Branch in Git Sync dialog.

TFS undo to last shelve

What I want to do: I made some changes in code and I want to make some kind of "checkpoint" (like git commit), then continue working and being able to simply undo changes to last "checkpoint". I don't want to use Check In.
If I'm not mistaken, it could be done by Shelving, but I'm unfortunately not sure how exactly I can achieve that.
Thank you.
In the "Pending Changes" tool window in Visual Studio just select "Shelve" at the top, enter a name and click the "Shelve" button:
To go back to your "Checkpoint", restore your Shelveset via Actions => Find Shelveset => Rightclick => Unshelve
Shelving is similar to stash in git. To replicate that kind of workflow would involve either checking out to a previous changeset and/or rolling back changesets. I've created multiple shelvesets before (V1, V2, etc), but it is less than ideal.

Do I need to Create New Branch in Git if I am must rolling back changes?

I Commited (call it Original). Then I made a bunch of changes.
Now I want to just roll them all back.
So I'm doing a Switch/Checkout. But I'm wondering if (and why) I need to Create New Branch (the default option).
First: Dropping commits means that you want to change the history. This might be problematic if you work with other people on a common repository and you already pushed your changes. - Either you do this rollback as described in the following text and force push (then you collaborators need to adjust their local history manually after pulling) or you revert the commits (option revert change by this commit) and push these changes (the revert is a normal commit which reverts the changes and will be automatically applied to your collaborators on pull).
If you really want to roll back all changes, the fastest way to go is to perform a "hard reset" to the revision you want to go back to (then the history and all files in the working tree are rolled back to the state of that revision, the other commits will be discarded as if those never happened).
If you want to keep one or more commits in the history, you should go for a rebase operation. Select the commit in the log dialog which should be the base for the "new" history and select "rebase onto this revision". Then flag all commits you want to drop as skip and perform the rebase.
cf. https://tortoisegit.org/docs/tortoisegit/tgit-dug-showlog.html#tgit-dug-showlog-actions and https://tortoisegit.org/docs/tortoisegit/tgit-dug-rebase.html
(Your itend to performa a "Switch" sounds like you have a SVN background; switch/checkout in Git means in generall that you want to switch to an existing branch or create a new branch).
see the documentation ...in that GUI it's called revert change by this commit:
Revert changes from which were made in the selected revision. All changes are integrated into your working tree. You may choose to commit immediately or edit and commit later. To abandon the reverted changes, perform a hard reset.

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 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