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.
Related
I'm new to git and I started making changes to a previous commit without creating a new branch. (oops)
Now my local version is no longer the current master. Trying to push the changes gives me the following error: "The current branch could not be determined." If I check out the current master, I can commit as normal, but I lose all the changes I made after the mistake (but save in a backup local copy).
How do I push my new changes without checking out the current master? (branch, merge, etc.)
Or how do I connect my existing project to a new repository and start over?
(I tried changing the repository location to a new url, but I still have to check out the master to push..)
If the answer requires terminal commands, baby steps would be appreciated.
Here is the simple solution I use always - when I start developing on the master branch and forget to create new branch.
1. git stash
2. git checkout -b new-branch-name
3. git stash apply
4. git add *
5. git commit -m "commit"
6. git push origin new-branch-name .
That's all :)
Also as you are beginner you should play and learn git by playing this game and you will solve your problems related git by yourself :)
I have searched everywhere and tried various solutions but am still getting the error:
Your local changes to the following files would be overwritten by merge
i have nothing to commit as status tells me the following:
# On branch develop
# Your branch is behind 'origin/develop' by 1 commit, and can be fast-forwarded.
# (use "git pull" to update your local branch)
#
nothing to commit, working directory clean
So then I do a git pull, then get the following:
Updating 67020e6..6dd23de
error: Your local changes to the following files would be overwritten by merge:
app/filename.php
Please, commit your changes or stash them before you can merge.
Aborting
But as I have nothing to commit and if I do a git stash I get No local changes to save
So how can I fix the problem and download and update my local machine with my remote amends.
Bit of history incase:
I have to local machines one at home and work I have done the amends at home and pushed them and I am now trying to update my local work machine with these updates.
EDIT UPDATE
As I cannot answer my own question for a while I found what for me solved this answer:
on the branch I wrote:
git reset --hard
Then the pull worked.
While looking around i tried the following that seemed to fix my issue at the time.
While on the branch i wrote.
git reset --hard
Had you ever previously done git update-index --assume-unchanged <file>? That could be a potential reason for your situation.
To fix, you do git update-index --no-assume-unchanged <file>. Then you should be able to stash your changes and continue with the merge.
Faced exactly the same problem. I was used to CVS before I started exploring git. I think running git pull --rebase origin master is the way to go for the kind of workflow that you and I use.
Refer to https://www.atlassian.com/git/workflows#!workflow-centralized for a more detailed explanation. I definitely know the answer is somewhere in that article, but I didn't understand the article completely.
I created a local branch from a git repository that I am working on. I have done this many times but for some reason the branch was created and put a bunch of random junk all over my code. (like random text and arrows).
So I decided to wipe the branch and attempt to recreate it since I have never seen this before. I went to switch branches and it would not let me because "Working copy is modified." I attempted to commit changes but it said there were none to commit.
I then went on the terminal and tried to commit, discard, delete the branch, change branches. All of these went unnoticed (either 'nothing to commit/discard' or 'cannot delete/change unmodified current branch').
I am now stuck, not being able to change branches, commit the "changes", discard changes, or remove the branch. Any thoughts?
Do the following:
git reset --hard HEAD
git checkout master
git branch -D <branch you want to delete>
This will reset all the changes you currently have. And then will checkout the master branch to continue working on. And finally delete the branch you want to remove.
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.
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>