As in question, I wonder if there is some documentation about what this Xcode command does (Source Control -> Discard all changes) ?
I guess it reverts to last commit but on local branch ? Can somebody confirm that it doesn't affect the same remote branch automatically ?
I didn't use git in XCode, but I can be so sure that Discard all changes will NOT affect history in the remote.
It will most probably discard all unstaged changes you made to the tracked files in the working directory, simply like executing git checkout -- . from the terminal.
With unstaged, it means changes you once executed git add -u for will not be discarded.
By the way, to find out what it actually does, a test by yourself is needed.
I ran into a similar problem in which I wanted to roll back to my most recent local commit, and being unfamiliar with command line git, I took a chance with selecting 'Discard Changes in /filename/' and it did exactly the same thing all the websites said git checkout would do.
Once again, this is just my "test" but the feature works as advertised.
Related
I have a Bitbucket repo where the most recent changes are pushed by another developer teammate. His push is more important and I want to make sure my local is same as the latest in the repo. I have not made any changes but still Xcode shows me this warning. I am fine is all my local is overwritten. How do I do it? Should I check the box when I am pulling changes in Xcode from the BitBucket repo? Or do I need to do a git pull from terminal?
If you want to merge another branch into yours, you should always commit your changes first. When conflicts emerge, you just solve them and there you go, you are on the latest commit with your changes preserved.
If, however, you prefer rebase instead of merge - you HAVE to commit your uncommited changes first, then you can rebase on the latest commit from the other developer's branch, the nice thing about rebase is that it keeps the git history cleaner while also leading you trough the conflict solving, because it basically tries to put each commit of yours on top of the commit that you are rebasing onto, so it sort of "guides" you trough resolving conflicts as you have small chunks of code to resolve and then continue rebase.
Try to read more on this. This article summarises the difference between merge and rebase:
https://www.freecodecamp.org/news/an-introduction-to-git-merge-and-rebase-what-they-are-and-how-to-use-them-131b863785f/
currently building a project clone and push all the changes to my github account step by step.
And i always used to see 'Twitter.xcodeproj/project.pbxproj' checked together with modified .swift files.
However, i don't see it now. I've reopened and did some additional changes to the code, but still nothing.
Is that ok, if it's not pushed?
And how do i get it back to normal if it's not?
The list you are looking at is generated by git status. Well, git status does not include any files that didn't change. So you should not expect to see project.pbxproj in the list unless you did something that would change it (like making a new code file and adding it to your project). Merely editing your existing code wouldn't change it, so it doesn't appear.
(In a way, this is a case of the classic confusion as to what git status means. Beginners often think that it's a list of your files, or a list of the files that will go into this commit. It isn't. A commit always contains all your files. But git doesn't bother to list them in the git status, because that could be an unnecessarily huge list. There are ways to find out what's in the commit, but the screen you are displaying is not how to do it.)
TL;DR Don't worry, be happy.
My iOS app is having a strange core data bug, and I contacted Apple's developer technical support for help. They are asking me to submit a copy of the offending code, so they can see what is going on exactly and help me identify the problem, but as one would expect I don't want to give them all my code, not only because it is proprietary but also because I want them to be able to identify the arts of the code that are having issues.
So I have removed 95% pf my code so that the app still builds and loads, and the problem can be demonstrated. I would like to provide them with a git repository, so that the developer who looks at my code can see how the changes I am making creates the bug.
However, I don't want to send them the whole git repository as it stands because the history would allow them to just go back in time, and undo all of the deleting work that I did. What is the proper way to go about "pruning" a copy of my git repository, so that a particular commit will become the root of the new commit tree?
You can delete a given file/files using git filter-branch.
See here:
https://www.kernel.org/pub/software/scm/git/docs/git-filter-branch.html
Specifically, you may use the following example to delete a file named as filename:
git filter-branch --index-filter 'git rm --cached --ignore-unmatch filename' HEAD
I can't figure out the best way to do this and it has happened a few times where I mess myself up that it'd be nice to know a possible good way for this. On master, I have our main project. We finally got approved to use ARC in iOS and I created a new branch for that to not mess with the main working master branch. I also took the time to delete some unneeded files in my ARCBranch. What I want to do is use this branch for development for the next release. I'd like to pull in the changes from master to the ARCBranch. So I switched to ARCBranch, and did
git pull origin master
I got conflicts, some which were straightforward because I could see the code, others being changes in the pbxproj file where I cannot tell what's what. I did see
<<< HEAD ==== >>>. I can't tell what I need to do here. I can't open it in Xcode, only a text editor. I tried just deleting those <<< === >>> characters since I saw one person on SO say that you typically want both changes and that you could always do that. This didn't work for me. I was wondering if there is a better way to do this change. Maybe somewhere where I can see each change by change happen? Thanks.
Instead, you could try
git rebase master
This would apply the changes commit by commit. If there are conflicts, it would stop there, so that you can resolve them and do
git rebase --continue
to finish applying all the patches.
It failed to auto merge so it marks the conflicting blocks of code and leaves them both so you can decide and remove one yourself.
I was working on my Rails project which is checked into Git. I read tutorials and they said for every time you start to change something, check out a branch.
However, accidentally I made some changes but did not check out a branch.
What should I do now?
What commands can I run so that Git takes my new changes and push them on my repository?
git stash
git checkout $correct_branch
git stash apply
Of course, if your changes are already on the branch you're going to put them on, just commit and go with it.
I hope you added a commit into jkp's answer. I can see somebody running that exact sequence without doing a commit and thus wiping out all their uncommitted changes...
It's not mandatory to make a branch, just best practice. It's perfectly legimate to work against master if you want. If you didn't create an explicit branch then you'll be working against master anyway and can push to that.