Pregunta

I edited files on home desktop and pushed to bitbucket.org as well as uploading to my test website. I then pulled from bitbucket.org to my laptop. It told me I needed to merge files but I did not know how so I copied files from test website into laptop local directory and continued my work. I think I mutt-led through the merge process and staged the changes (Not sure if I did commit) using gitg.

When I try to push to bitbucket.org from laptop my problems and ignorance became more apparent:

kurt@tosh ~/Public/laddercms $ git status

On branch NumPermit
Your branch is ahead of 'origin/NumPermit' by 2 commits.

nothing to commit (working directory clean)

kurt@tosh ~/Public/laddercms $ git push -u origin NumPermit 

Password
for 'https--kurtjensen@bitbucket.org':  To
https--kurtjensen@bitbucket.org/kurtjensen/laddercms.git  !

[rejected]        NumPermit -> NumPermit (non-fast-forward) error:
failed to push some refs to 'https--kurtjensen@bitbucket.org/kurtjensen/laddercms.git' 
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.

kurt@tosh ~/Public/laddercms $ git pull origin NumPermit 

Password for
'https--kurtjensen@bitbucket.org':  From
https--bitbucket.org/kurtjensen/laddercms  * branch           

NumPermit  -> FETCH_HEAD Auto-merging profile/ajax/ProfileForm.php

CONFLICT (content): Merge conflict in profile/ajax/ProfileForm.php
Auto-merging Core/protect.php 

CONFLICT (content): Merge conflict in Core/protect.php Auto-merging 
Core/class.credentials.php 

CONFLICT (content): Merge conflict in Core/class.credentials.php 
Auto-merging Core/class.access.php 

CONFLICT (content): Merge conflict in Core/class.access.php Automatic
merge failed; fix conflicts and then commit the result.

My local laptop files are the ones I want to keep (I trust them most as being correct.)

now in gitk I see:

Author: Committer: Parent: 9d2cd77d4250bbf71e367021acf65e2c2465d0df (New Protect.php is working as far as I know even with NLIKey) Child: 0000000000000000000000000000000000000000 (Local uncommitted changes, not checked in to index) Branch: Follows: Precedes:

Local changes checked in to index but not committed

How do I restore the world on (Desktop, Laptop, bitbucket) to this "Commit/checked in" point?

Thanks in advance...

Quote: "Messes are my specialty."

¿Fue útil?

Solución

Some info which will save you the hassle next time:

It told me I needed to merge files but I did not know how so I copied files from test website into laptop local directory and continued my work

When you push to bitbucket form your desktop, you should have done the following on your laptop:

git fetch origin
git checkout master
git merge origin/master

The fetch retrieves all the recent changes on the remote branches, the checkout places you in whatever local branch you want to merge into (master in this case), and the merge command says to merge whatever is in origin/master into your local branch master. This is a really basic workflow, and 2 ppl working on the same project would follow that.

Anyways, for a quick and dirty way to recover without preserving the history, I'd simply delete the .git folder, then run git init in the root folder, git remote add <alias> <url> and git add . + git push alias master -f. For a smarter way to recover, you would need to provide more info on your git's status and clean up your post a bit.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top