How to discard latest github push made with Xcode - github

I have been using Xcode with GitHub. I committed some bad data and I want to revert the merger. How might I do that? Or is there no way of doing it through Xcode? I am using Xcode5.

Xcode does not allow you to do this, but Github for Mac does a good job at bringing back a previous commit: https://mac.github.com
Add your repository to GitHub for Mac, then click the History tab. From the list on the left, pick the commit you'd like to bring back. You'll see what's changed in the window on the right (a diff across multiple files).
To bring back your previous commit, click the little gear icon above the diff window and you'll have two choices: "revert" and "roll back".
From what I understand "revert" undoes only the changes of said commit, whereas "roll back" will change the entire code to the state as it was in this commit. If you only go back a single commit there's no difference, but when you go back several commits then "roll back" is like going back in history, while "revert" leaves the other commits intact.

Related

Clicked reset branch to current commit and lost all my work, what the heck have I done?

I am brand new to Source Tree and have no idea what Im doing but I hope I didn't just lose my work.
I clicked a button that says reset branch to current commit, and chose the "Mixed" Option. I then pushed my files. But after going back into UE4 (a program Im tracking) I noticed that my files have gone back a really long time. I can see all the files I have in the "Working Copy" section of source tree, but all of them say "Missing" and am too afraid of doing anything in fear of losing it all. I need help on what button to press to undo my changes (CTRL Z DOESNT WORK :( )
Here are some pictures of where I am.
If it says "Working Copy" and I am able to click "Open Before" I assume the files still exist, I hope.
If I can, how do I get my Files back to the way they were before I messed up.
If you committed the changes before using the reset branch, the changes are not lost.
I'll explain this using command line commands, but I guess there are advanced GUIs that can achieve the same thing.
Open a command line interface of your choosing that has access to git commands, then navigate to the project folder
$ cd /path/to/project/root
Next, check the git reflog
$ git reflog
874333c HEAD#{0}: reset: moving to 874333c
5dc3401 HEAD#{1}: commit: committed something awesome
4ef6395 HEAD#{2}: commit: fixed bug related to ballistics computation
d5cb3b3 HEAD#{3}: commit: added ballistics computation
What you want to do now is to reset your branch again, but this time to the state it was in before (ie. 5dc3401) you did a reset to the current state it's in
$ git reset 5dc3401

Numbers on the push and pull button of SourceTree won't change

I started using SourceTree few days ago and after I committed and pushed my changes to the remote GitHub repository, the numbers on the buttons remain the same, for example if the number on the push button becomes 3 when I committed a change, after I pushed it; it needs to be 0 or empty. But that's not the case here, it remains the same even though it has successfully been pushed. I also checked that my changes had been pushed using a web browser by going to the GitHub site. Is it because of the branch that I have pulled from and am pushing to are different or something else? Can any one please help cause I don't understand it... Thanks!
The numbers shown on the right hand side of the Branches panel reflect how many commits ahead or behind the Tracking Branch you currently are. If the numbers aren't what you expect, you should verify that the branch is tracking what you actually want.
You can verify the tracking branch by right clicking your local branch (as depicted below) and expanding the Track remote branch menu item. Finally, if you want to change the tracking branch simply click the new target from the list and Sourcetree will update accordingly. Hopefully that helps make sense of the disconnect that can happen when you rename branches and provides some details around why it happens and a simple way to resolve.
The same thing also happened to me too, I was working on branch I had push everting but was keeping appearing one unsend Push and miraculously also appear unsend Push on Master.
So what did was the same as Hristo Staykov and Sammie remove the Master branch from my local computer, since I had one miraculously unsend Push on Master did need to run this line terminal to remove the branch:
git branch -D master
And then Repository > Refresh Remote Status
I simply use the keyboard shortcut from the Repository menu:
CTRL+ALT+R (or control+option+R if you prefer)
My guess is that the shortcut would be the same or at least similar on Windows. Just look for the option called Refresh Remote Status under the Repository menu.

Egit at Eclipse: can I see changes in files on commit screen?

I need preview like in IntelliJ IDEA. Strange that this is not the default behaviour.
Yes very strange. I solved that using the Git Staging view.
Go to Window -> Show view -> Other, and select Git Staging.
There you can see all you need in order to do a proper commit, unstaged changes, changes, even conflicts. And of course you can do a commit or commit and push directly.
I think the idea in Eclipse is to do commits from synchronization view and to be consistent between different team providers. The former comes from old times when CVS and SVN ruled. Nowadays it seems to be a cumbersome way to do it.
Heck, even SVN team providers allow you to revert changes from the Java view while from EGit you can either reset the whole working copy or you need to go to Synchronization view and use cryptic Overwrite option for a single element. Of course changes in files that you're asking about are there.

Github for mac - pushing selected files only

I'm new to github and currently only starting off using github for mac.
I have taken a clone of my client's website and made some development changes locally. Note: I'm literally working with the files in the directory I sync with.
I want to push only one small change as the rest is still under development. Is it possible to push only the one file?
Git pushes deal with commits, not files. You'll need to create a commit that contains your selected changes. This is one area where Git's index is really handy.
Let's say you've modified two files, foo and bar.
If you want to commit only the changes to foo, using the command line you can do
git add foo
git commit
This will create a new commit updating foo, but bar's changes will remain only in your working copy. You can now push the new commit.
It's been a while since I've used the graphical GitHub tools, and I've only used them on Windows, but I believe the way to commit only certain files is to check or uncheck the box beside each file before you commit. You can see these checkboxes in their documentation:
You can go even further. If some of the changes in bar should be part of a commit, but not all of them, you can do something like git add --patch, which will break your changes up into chunks and prompt you for the ones to add to the index (these are the ones that will be included when you commit).
On GitHub for Mac you can do this too:
Select one or more lines to commit by clicking on the line numbers in the gutter. In the latest release, you can select a block of changes at a time. Hover over the right hand side of the line numbers to get a preview of what will be selected, and click to select.
See the documentation for git-add for details.

Eclipse 'Git Repository' perspective vs. 'Team Synchronizing'

I'm trying to rationalize two perspectives which seem to be related (or at least provide very similar functionality): The 'Git Repository' perspective (which I got after adding EGit), and the 'Team Synchronizing' perspective (which I think was part of the EE distribution).
As far as I can tell, I was able to get the Git Repository working (with GitHub), or at least most of the features: The 'Git Staging' Window is working fine, I'm able to commit by dragging files from 'Unstaged changes' to 'Staged changes' and then clicking the Commit icon. Then I'm able to push my changes from the 'Git Repositories' window, by right clicking on the workspace->Remotes->origin->url, and select Push from menu (is that the 'correct' procedure?).
With the 'Team Synchronizing' perspective, I'm no luck to even set it up. Once selecting the 'Synchronize...' frmo the menu, the Git, then I see a table (what is it?). I'm trying various values for the Destination (otherwise, unable to hit the Finish button), but no matter what I do, it tells me 'no changes' for all my projects.
There are also many context-menu item when right clicking on a project, and selecting 'Team'. What are these?
In CVS the Team Synchronize is about the only sane way of managing your incoming and outgoing changes. You can update / merge incoming changes and commit outgoing changes from this one view. Since every commit is discrete and it is non-atomic, the view is fine for this workflow.
In EGit however you already have explicit actions for adding, committing, pushing, pulling and merging. So the team synchronize is largely outside the normal workflow. It behaves much like a glorified synching from a patch - you pick which branch(s) you wish to compare your working directory and it shows you the differences. You can then apply those changes en masse or individually but it's not going to pick up the context, i.e. it's not going to create merge points or whatnot.
So you should train yourself not to use except for exceptional reasons. For example, maybe you have two branches A & B. Somebody committed a change to B and you need only a small part of it, so you could use Team Sync to show the diffs and only apply the ones you need. Or maybe you just want to squash up all the changes on branch B and call them a single commit in A. Then you might use Team Sync rather than screwing around with a rebase when you're going to toss B anyway or its a remote branch.
From my understanding, the "Git repository" perspective is intended for committing files from the working directory to the local Git repository, while the "Team synchronizing" perspective is for syncing your local repository with a remote one.
I found this confusing at first as well, because when using SVN, the "Team sync" perspective was for committing/updating files. Until I noticed that in EGit's Team sync perspective, instead of showing the commit/update buttons, it has the pull/push buttons, which are for syncing two Git repositories.
For the various options that appear under the "Team" context menu, they correspond to a bunch of Git operations. I'd suggest some reading about Git's principle of operation before using EGit. http://git-scm.com/doc would be a good start.