Can't push on a remote git branch in xcode - xcode

I come to you because I have this really annoying issue. In xCode, I deleted some files and now, when I want to push my sources, it says that I can't since there is some uncommitted change. The uncommitted change come from the deleted files (xcode shows me these files marked with a d).
My question is how I make my git repo sync with it so I can push my sources ??

In addition to the answer of triad:
Select your project in the Project Navigator
Select under the File menu->Source Control->Commit
Select under the File menu->Source Control->Push (if you want to push it to a remote repo)
On the Mac it helps to research the items under the menu bar, as the popup menu is not always populated fully.

You need to commit your changes before you push onto your remote. If you go to your project directory, type:
git status
It should show you the files which have been deleted. If it looks okay to you, type:
git commit -a -m "your commit message here"
Then you should be able to push to your remote repo:
git push <remote> <remote_branch>

Related

Git sync with GitHub repository

I have a desktop PC and a laptop, I use both daily to commit to the same repository on GitHub (via Git). I have just moved over and started using Git, which is great. However, what command do I use when, for example, I have made changes on my desktop PC and committed them to GitHub, and then I want to move all of the changes currently on GitHub onto my laptop files to resume my work on my laptop where I left off on my desktop PC / GitHub?
Thanks in advance.
Clone a repository into a new directory ;
git clone uri_repository.git
Incorporates changes from a remote repository into the current branch.
git pull
Show the working tree status.
git status
Update the index using the current content found in the working tree.
git add .
Record changes to the repository.
git commit -m 'message'
Update remote references (refs) along with associated objects.
git push
To fetch your code from your remote repository from GitHub you use the command git pull. This fetches the latest changes and merges them with your local code so you have the most recent code. You can find a Git cheat sheet with most of the commands you will need here
You can use the following command to syn your remote repository to your local repository
/* origin points to your remote repository, master is the branch in which your working */
git pull origin master
Incase you dont have remote ie origin setup then
/* Here your aliasing your remote repository location to origin, you can name it anything */
git remote add origin your_git_repo_url
In case if you dont know which branch your currently working then
/* This will list all the branches with * preceded which is active one */
git branch
Once you do your local changes then you may want to push the code to remote repository which can be done as follows
git add .
OR
git add file1.txt file2.txt
git commit -m "You commit description"
git push origin master

xcode9 "The current branch could not be determined"

pushing to github was working fine. I think this problem started when i checked out a branch from github. How do i fix this? When i try to push to github now, i get the error "The current branch could not be determined."
Also, all my local commits do not show up with comments in either of my local branches. at least not in xcode 9 UI. I don't really know how to use the local git to check these things, so if someone wants to point me to documentation that would be helpful too.
I had this issue, you need to get down and dirty in Terminal :)
The issue is most likely a detached HEAD
This recovery is based on you have made changes whilst head detached and you want to keep these changes.
Navigate to your project directory and execute: git status
If you have a HEAD detached message then:
Commit changes: git commit -a -m "you commit comment here"
Create a local temp branch: git branch temp
Check out the previous branch (the branch you want to use i.e. master): git checkout master
now merge your recent changes (from the temp branch): git merge temp
Your all done, go back into Xcode and your back on your branch and everything as you left it :)
Hope this helps.
Type these commands (1-4) sequentially in your Command Prompt :
git commit -a -m "you commit message here"
git branch temporary
git checkout master
git merge temporary
Now head over to source control navigator pane in your Xcode project and delete the "temporary" branch from Branches Tab
Source Control navigator pane image
I had the same issue after checking out a previous commit and have found a fix.
In Xcode go to Source Control > Clone > Clone the repository you are trying to push and save it, then delete your old Xcode project and replace it with the cloned project and it should work as normal.

Git Push is working via Terminal but not via Xcode

I've created a remote git repository on my local computer inside Google Drive folder
git init --bare project.git
and added the remote path as follows
git remote add origin '~/Google Drive/git/project.git'
When I commit via Xcode, it rightly shows the push option check box with correct branch (master in this case). I marked it checked and then press 'Commit and Push' and apparently it does so but actually not pushing to remote repository. When I push from 'Source Control -> Push', it shows successful message but my remote repository doesn't get updated.
When I run the push command from terminal then it does update the remote repository successfully.
git push origin master
How to fix so that Xcode (7.1.1) can push successfully?
Edited: A side note, this has troubled me a lot by the time I realized this. As initially, I think it was working via Xcode (maybe some prior version to 7) as well.
Edited: #VonC here is how I know how git push is working. The modified date gets changed for some objects in finder.
Edited: As per instruction by #VonC, now the push is working from Xcode when project.git is moved at different location out of 'Google Drive' folder. But, I want it to work with 'Google Drive' folder.
Edited: I further moved the project.git to a folder with name including space and again xcode is not pushing but terminal is still pushing.
Xcode 7.1 doesn't push to remote repo path with a space but Terminal does provided that the path is enclosed in quotes. Hope Apple would fix it for new releases.
I've got my issue fixed by renaming the 'Goolge Drive' to 'GoogleDrive' and adjusted the remote path accordingly. Google Drive App prompted for missing folder and I pointed it to the renamed one.
my remote repository doesn't get updated.
Try simply to clone that repo repo elsewhere to see if you get back the content you just pushed:
git clone ~/Google Drive/git/project.git /somewhere/else
Don't forget that a bare repo has no working tree, so after a push, you don't see any new file.
Note: if a remote repo path with a space is problematic to XCode, a possible workaround would be to push to a path without path:
either one which is a symlink to Google Drive
or a path which is rsync'ed after to Google Drive

Stuck in git loop

I had an issue where I accidentally copied a directory into a subdirectory of itself thus creating thousands of git transactions. After unsuccessfully trying to clean that up, I decided to create a new project and copy the files over from the old one. Somehow I think I've messed git up, but I'm not sure where the problem is. Here are my current symptoms.
I thought I initialized the git repository correctly. However, none of the files exist on github.
https://github.com/victorengel/matchismo2
... except what I created there.
The project itself is an iOS single view application that I created with git enabled. I copied over all the files I needed from the old project to the new project area, confirmed that it ran, and then tried a commit. The commit seemed to work, but the push didn't.
If I tried a push, I got a message that the working copy is out of date and that I should do a pull. If I tried a pull, it said there were uncommitted changes and I should abandon them or commit them. After some rooting around, I figured out that the change triggering this was a user data change that should have been ignored in .gitignore.
I finally have the .gitignore set up the way it needs to be. I think the repository is set up right on github.com, but I'm still getting errors.
I can commit but not push. If I try to push I get the message "Working copy out of date. Try pulling from the remote to get the latest changes, then push again."
If I try a pull, I get the message "matchismo2/master" is not a valid remote branch to pull from. Please choose a different remote branch.
Looking around at github.com, there is only one branch, master under victorengel/matchismo2. To me it looks like everything is set up properly, but apparently I'm missing something. What is it?
In Xcode, in the organizer, if I click on Branches, there is one item listed: master.
If I click on Remotes, there is one item, matchismo2, and if I expand it, master is listed.
I've been assuming this matchismo2 with master underneath it is what is supposed to match the "matchismo2/master" that's in the error message. Looks like a match to me, so why isn't it working?
EDIT:
If I try pulling from the GitHub application, I get an error message "There aren't any remote branches on the server yet." If I try publishing from GitHub, I get the following:
git: 'credential-osxkeychain' is not a git command. See 'git --help'.
2013-03-05 16:32:43.680 GitHub for Mac Login[68518:707] AskPass with arguments: (
"/Users/brillig/Downloads/GitHub.app/Contents/MacOS/GitHub for Mac Login",
"Password for 'https://victorengel#github.com': "
)
2013-03-05 16:32:43.763 GitHub for Mac Login[68518:707] Error reading attributes: OSStatus -2033889429
2013-03-05 16:32:43.764 GitHub for Mac Login[68518:707] Error reading attributes: OSStatus -2033889429
2013-03-05 16:32:43.919 GitHub for Mac Login[68518:707] Error reading attributes for password: OSStatus 840183217
git: 'credential-osxkeychain' is not a git command. See 'git --help'.
To https://victorengel#github.com/victorengel/matchismo2.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://victorengel#github.com/victorengel/matchismo2.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
(256)
How about ensuring all your files are in order, renaming your branch, and pushing to the new (renamed branch) ? Then once you determine everything you need is actually there and your new code works, you can force update the master. Not an ideal way to do it, but it might work for you.

Github failed push

So to make a long story short, I've been working on a web app for the past few months. Recently I had to get a new laptop and cloned the repository from github onto my new machine... However whenever I commit changes to my app and attempt to use git push -u in the app's root directory i get the following message:
To git#github.com:acc/etc.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'git#github.com:acc/etc.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again. See the
'Note about fast-forwards' section of 'git push --help' for details.
but when I try git pull git#github.com:acc/etc.git master I get a message telling me that the pull was aborted.
From github.com:acc/etc
* branch master -> FETCH_HEAD
error: Your local changes to the following files would be overwritten by merge:
config/routes.rb
test/fixtures/users.yml
Please, commit your changes or stash them before you can merge.
Aborting
so then i commit my changes using git commit -m 'fixing' and then attempt git pull again.
however this time I got messages stating that practically all my files had an "Auto-Merging CONFLICT"
am i totally screwed with this particular repository? I'm not really sure what to do since git is still somewhat new to me....
am i totally screwed with this particular repository?
No, but you will have to do a manual merge, since Git can't figure it out. git status will tell you which files need editing. The files themselves contain markers indicating where you should edit. When that's done, git push should work again.
If the changes aren't that big, consider making a copy of the entire folder/project in a different directory outside of the project, then git reset --hard HEAD will wipe out, erase and delete your recent changes.
You can then apply them again individually using your save3d copies for refernce.
Make sure sure you git add before git commit of course.
Finally if you get auto commit merge issues you can always just edit the files manually to resolve.

Resources