Unable to push or pull from Xcode - xcode

I committed some changes in my Xcode project and tried to push them, but I am prompted with: "The local repository is out of date."
Then I tried to pull as they said, but then I am prompted with: "The working copy has conflicting, uncommitted changes."
I really need to commit these changes, and I am scared of losing them if I do any wrong step. What should I do?
Thanks

A opportunity is to git stash (cache) your local changes and then git pull the changes from remote. Then your local code is up-to-date with the remote.
After pulling, with git stash pop your stashed changes would be reapplied.
But be careful, there can be merge conflicts.
Now you are able to git commit and git push your local changes to the remote repository.

Related

Sync Git Branch to a specific folder

Suppose I have a git repo named waterkingdom It has lot of branches. We will be working with a specific branch called wave-pool.
wave-pool branch has files & folders such as
cost.txt
ride.txt
rules.txt
code/
code/ride.py
code/boom/crash.py
We have another folder which is not a part of the repo named wave-pool-boom
How can I only sync the branch wave-pool from waterkingdom repo to the folder called wave-pool-boom after the commit without knowing the latest commit hash?
Everything is locally on Linux.
How can I only sync the branch wave-pool from waterkingdom repo to the folder called wave-pool-boom after the commit without knowing the latest commit hash??
Everything is locally on LINUX.
Pushing branches from one repo to another is easily done in git, and makes a lot of sense the more you work with git.
Clone waterkingdom into a new directory
git clone --single-branch -b wave-pool /path/to/waterkingdom ~/projects/waterkingdom
cd ~/projects/waterkingdom
Setup a new remote
git remote add r-wave-pool-boom /path/to/wave-pool-boom
Push the branch to the remote (but do not change its tracked remote branch)
git push r-wave-pool-boom wave-pool
Remove the remote (optional)
git remote remove r-wave-pool-boom
Tools to help you further your Git knowledge
git branch -avv
Gives a listing of all branches and what remote branch (if any) they track, what the latest commit hash/message is, and the state (behind, ahead) of each branch.
git remote -v
Give a listing of all the remotes (if any) and their URL's configured for your local repo.
Further comments
Why "without knowing the latest commit hash"? The latest commit hash is always HEAD or <branch-name> or refs/remotes/origin/<branch-name>.

Push current code to existing GitHub repository

I have several Visual Studio solutions that have both a local repository and one on GitHub. I've already made many changes and successfully pushed those changes to GitHub.
But now Visual Studio has forgotten that one of my local repositories is associated with a GitHub repository and I can't seem to figure out how to reconnect it. In fact, it no longer lists that repository in my list of GitHub repositories.
In the image below, you can see I have a local repository called Toxic, but that repository does not appear in the list of GitHub repositories. If I try publishing the Toxic project to GitHub, it just tells me the repository already exists.
How the heck can I get all of my existing Github repositories to show up in the top section shown above so I can push my latest changes?
it appears the only option is to clone the GitHub repository locally, copy my modified files over the newly created repository, and then check in my changes.
Try fist:
installing Git for Windows (command-line)
cloning your remote repo in a new folder
adding your existing repository as a remote
fetching and see if you can cherry-pick your commits
That is:
git clone https://github.com/<user>/<repo> newFolder
cd newFolder
git remote add old ../path/to/old/local/repo
git fetch old
git log old/master
git cherry-pick old-sha1..old/master
(with old-sha1 being the first commit you want back)
Then add the newFolder in your Visual Studio workspace, and see if everything works (do a modification, add, commit and push)
Unless I'm missing something, it appears the only option is to clone the GitHub repository locally, copy my modified files over the newly created repository, and then check in my changes.
Of course, I lose all my comments and iterations since the last check in to GitHub. And care had to be taken not to delete the .git folder, and to copy over all changed file and delete any that had been removed. Seems like there should be an easier way but this certainly did the trick.
I'm no git expert, but I think I might be able to help, if I'm not too late.
Run:
git remote -v
This should print something in the form of:
origin <remote_repo_url> (fetch)
origin <remote_repo_url> (push)
If you only see:
origin (fetch)
origin (push)
try running:
git remote set-url origin <remote_repo_url>
If you get no output then run:
git remote add origin <remote_repo_url>
And then try
git push -u origin
The -u or --set-upstream flag will set origin as the default repo for your branches.

Reinitializing a git repository

I have an xcode project on my desktop in a directory that originally had a git repository with a tracking branch that tracked a remote branch on github. The remote branch has some 84 commits and is 2 commits ahead of the master branch of the project I'm adding features to. I changed the name of the folder/directory on my desktop. I'm not 100% sure if this is the reason why but when I go to git status I get: fatal: Not a git repository (or any of the parent directories): .git. My plan is to simply git Init, add the remote branch and create a new tracking branch and than commit locally to that branch and than push to the remote branch. However, I'm a git beginner and I'm not sure if this is the proper way to go about it. I'm very weary of losing any commit history or accidentally breaking something. Is the method I outlined a good way of rectifying this loss of the git repo?
If you have all your code updated in remote repo then your local .git is deleted. You don't need to re-init your local repo. Rather just clone it.
git clone remote_repo
If you don't have any commit in remote repo, Simply follow
git init
git add all_local_files
If you have updated remote repo than some commits made in local but not pushed and you lost .git. Simply clone remote. Add all files in a single commit
git clone
git add all_local_files
Looks like you messed up your git repository, but not the code / contents.
One way to restore and keep local changes ( if any ) would be:
Clone another copy of your repo from github.
Copy all modified files to the new repo, omitting removed ones: rsync -duztv /old/local/repo/ /new/local/repo
git status to see what the situation is.

revert git back initial condition

I was trying to add a repository to my xcode project, but instead of adding my project files to the repository, git removed my entire project. I think I can use 'git revert' option to revert the changes, but how do I know where to revert to?
Get the list of commits using
git log this will list out all the commits with its hash, to revert the commit use
git revert (part of the hash)
for example if the commit hash is adghgd356484fghfbht76, do
git revert adghgd3564
If you have not pushed your changes to remote, you can run git reset --hard which will undo all your local changes and you will loose those changes from the history as well

Git: cannot open .pbxproj file error after renaming Xcode project and pulling changes

I renamed our iOS project (client finally chose a name) following instructions in the most upvoted answer here. I pushed my changes. Now, when my teammates pull, they cannot open the project because Xcode cannot find the .pbxproj file. They subsequently reset to their good local versions.
As usual when I royally f**k up I tried a hard reset to the last good commit, planning to force push the good commit up to the remote. While the reset was 'sucessful', it didn't change the newName.pbxproj back to oldName.pbxproj. So I could not open the project. Checking out my faulty commit didn't help things either. I am back at square one.
.pbxproj is NOT in our .gitignore:
*.DS_Store
*.xcodeproj/xcuserdata/*.xcuserdatad
*.xcodeproj/project.xcworkspace/xcuserdata/*.xcuserdatad
*/*.xcodeproj/xcuserdata/*.xcuserdatad
*/*.xcodeproj/project.xcworkspace/xcuserdata/*.xcuserdatad
The only thing I can think of now is to reclone the project from a specific remote commit. How can I do this? Other options? Why won't a renamed .pbxproj transfer over in a pull?
If you do a git log -5 it will show your last 5 commits. Determine the version before you named the file, and you can do a git reset --hard HEAD~<number> where <number> is how many commits you want to go back.
Alternatively, with your renamed proj file, you could try to blow away your remote with a git push origin :branchName then push your local changed branch up to the remote git push origin branchName
Then, have your other team members do a pull from the newly pushed remote.

Resources