I did a commit on friday, discard all changes on monday, now all my pod related files are in the trash. I realise I probably did something wrong, as I'm quite inexperienced with git etc, but now i really need to restore all my files.
Has anyone come across this before and know what to do?
Description
This should revert your home directory to state the state it was prior to those changes you refer to in original post.
Example
Run git reflog
Find HEAD#{ID} (Ex. HEAD#{1},HEAD#{2} etc.) prior to changes that you've made
Run git reset --hard HEAD#{ID} (ID is a number refering to a particular HEAD as described in point 2.
Reference
git reflog
Useful link
Recovering Lost Commits with Git Reflog and Reset
Alright, incase I ever do this accidentally again (I've done it before), this is what to do.
Basically, it's the pod files that went.
Run sudo gem install cocoapods
Add .xcodeproj/project.pbxproj file back, for some reason it was put in the trash when I selected 'Discard All Changes'
Run pod Init
Add details to that file, then run pod Install.
Related
I am not very familiar with git as I just use it in the most basic manner. Lately I've been running into this strange behavior which makes no sense to me and causes a huge disturbance in my productivity. For certain branches when I run git pull instead of just getting the latest commits from the remote repository like I expect, I get an ENORMOUS list of modified/deleted/added files as well as an enormous list of untracked files. The branch I am pulling from is our team's master branch. I am just trying to keep my local copy of master in sync. What are these other untracked files showing up as well as these modified files? I didn't touch any of these other files.
What makes the problem worse is that I can't delete these untracked files or anything. I've tried `git clean -fx' and it only removes 3-4 files but still leaves hundreds. At this point I just want to get rid of all of these files, delete the branch, and pull the branch from remote again.
I tried doing the following:
git fetch --all
git reset --hard origin/<remote_branch_name>
but I received an error because Git couldn't create a symbolic link. I am using Git on Windows.
Why is git pull doing this, and what should I do?
EDIT: I was finally able to run the git reset command when I ran my prompt as an admin, but it still doesn't explain this weird git pull behavior.
It seems to me that the 'git pull' action did not complete successfully.
It is possible that you modified some of the files as an admin, and when pulling as non-admin user git tries to modify or delete a file and has no permissions to it.
Therefore you stay in some half baked state.
What do you see when you run git status?
Is there any error in the git pull?
I have this file in working directory called Gemfile.lock. Basically, this file gets refreshed every time another file Gemfile gets modified. But I was able to
git stash
Gemfile but Gemfile.lock did not get put in stash. So then I tried
git checkout Gemfile.lock
and
git checkout -- Gemfile.lock
But everytime I run 'git status', it remains highlighted in red in the working directory. I do not want to add it to the staging area to be committed to my local repository and ultimately the remote repository. But I also want to
git checkout
to another branch. But this file being in the working directory is preventing me from switching branches. What can I do?
Keep in mind, I do not want to add this file to .gitignore and invoke 'git rm --cached <file-name>', because I do want this file to be tracked in git. I just do not want my current revision to be tracked.
I had a case where spring caused troubles. Never figured out what happened. Should you use rails with spring, then try spring stop first.
I've accidentally commited my cocoapods project from my workspace into a branch.
Now that I need to merge the branch back to the master branch, I can't proceed.
I've been through all all of the files and accepted the changes in each files (which took quite a long time), however the merge aborted, with a message saying it couldn't overwrite local files.
I'd like to remove cocoapods and not have changes under git. However, I'm not sure how to proceed. I've seen that you can remove find at the command line, but I'm concerned as I'm in a branch.
Help!
What you need is probably the filter-branch feature of Git to remove some files from every commits: https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History#The-Nuclear-Option:-filter-branch
Try something like below on your branch:
git filter-branch --tree-filter 'rm -rf <yourCocoapods>' HEAD
In the end I physically deleted my pods folder, then committed the deleted files. I was then able to merge :)
I have a few Cocoapods installed for my project. For one particular pod, KVNProgress, Xcode doesn't commit it to GitHub. Each time I check my project out I get 'can't find KVNProgress.h' blah blah...
So I run 'pod update' from terminal and immediately all is fixed.
After running 'pod update', I check my project navigator and there are no 'A' or 'M' or anything else for that matter indicated a new or modified file. Therefor nothing to commit.
Any ideas how to fix this so I don't have to update the pods each time I check out the project?
You should use the Terminal to figure out if it's an Xcode problem or a git problem.
Run git status --ignored in the project directory. If the Pods directory is shown in the Ignored files section you have to remove Pods from your .gitignore file.
If the files appear in the untracked files section Xcode messed up the git status.
You can use git add . to add all untracked files.
As a side note, I would recommend to use a dedicated git client like SourceTree, GitHub Mac, or Tower instead of Xcode. Xcodes git implementation is not the best (feature wise) and it's a bit buggy.
I'm at a point where I realized I took some actions that were the equivalent of entering a cave without a flashlight. Hopefully this retelling of events will contain an indication of what went wrong.
I began at my project's master branch. I performed a git pull from the remote master (to make sure I had the most recent build), then a git checkout -b newFeature. With this newFeature branch, I made some changes, including adding a 700mb .mp4 file. I then committed my changes with git commit -a -m "New features and a big mp4 file..." I never pushed the changes to the remote. Made some more changes, decided I didn't want them, so I did a git stash at the end of the day.
This morning, I switched to master branch, where I did a git/status. I noticed my local master branch was now ahead of the remote master, which was odd because they should have been exactly the same. I also noticed that when I built my iOS app (from master, NOT newFeature) that the app size was 700mb bigger than it should have been.
Now this part is where I started panicking, so I apologize if the order of events is not completely accurate...
I saw that my .mp4 file was an unstaged file after running git status.
I tried to do a git reset HEAD <file>, which seemed to remove the file, but it still showed up in my builds.
I then tried git rebase, but never got through it because I seemed to hit a loop where all git rebase --continue did was end up at the same place over and over, so I aborted (I've never done a rebase before).
Giving up, I deleted all of my local files (or at least I think I did), restarted my computer (you never know), cloned everything from GitHub... and my builds are still including the large mp4 file.
I cannot seem to find the mp4 file, though it is clearly there when I build the app. I never pushed it to the remote, not that it would have let me anyway due to GitHub's restraints.
Any solutions, bread crumbs, or whatever would be greatly appreciated!! Thanks!
EDIT:
I attempted to go back to the build before I ever made the newFeature branch using git reset --hard , still no luck, as my project will still build with the mp4 file.
Perhaps I could find where this mp4 file is store locally? I can not find it in my project folder.
SOLVED:
See my answer below... long story short, I needed to Clean my build in Xcode (Cmd-shift-K) to remove the MP4 from the build folder.
Try git clean to remove any extra files. You should also check the logs of your build system to find out where this file is getting included.
Of course it's something I should have done right from the get-go. I've read before, "Before building your project, do a Clean on your build" (Cmd-Shift-K in Xcode). After running a disk report on my drive (using JDiskReport), I found the mp4 file cached in Xcode's DerivedData folder in my Library folder. Doing a Clean on the build removed the file from this folder, and no other future builds included it.
I guess I never ran across a time when not performing a Clean was really evident. When I was restarting Xcode, I wrongly assumed any sort of cache clearing would be done then.
So turns out this wasn't a problem with git directly, but with Xcode. I'm not sure if it should be the correct behavior or not, but I will now be run a Clean whenever switching between branches.