Solved

Git push without pull?

Posted on 2014-04-04
2
2,562 Views
Last Modified: 2014-04-08
Working on server, that got a drive replaced with the .git folder being moved.

Now we have a new drive and a bunch of work down on various scripts and programs.

When we go to push the work to the git repository we get:

 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://github.com/...'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first merge the remote changes (e.g.,
hint: 'git pull') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

The work on the server is the most current and we want to keep it and make it master.

What is the easiest way to do this without losing the current scripts.
0
Comment
Question by:freshgrill
2 Comments
 
LVL 34

Accepted Solution

by:
Duncan Roe earned 500 total points
ID: 39979996
I would git clone the remote repository to another location. Then use diffdir (attached) to see whether perhaps there are changes on the remote that you would like to keep.
Assuming there are no such changes or you have merged them into your local tree and committed them there, trecpy (also attached) your local tree to another different location. In this location, do a git pull. mv .git from your local tree to a safe place. mv .git from the other different location to your local tree. git status, git diff and git commit -a in your local tree as required. Then you can do your git push
diffdir
trecpy
0
 

Author Closing Comment

by:freshgrill
ID: 39987399
Worked perfectly. Thanks
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

When working in a large software development team, whether you have many developers working on the same projects, or your project is linked to other projects; it is very important that developers regularly perform "get latest" to ensure that the cha…
I am a long time windows user and for me it is normal to have spaces in directory and file names. Changing to Linux I found myself frustrated when I moved my windows data over to my new Linux computer. The problem occurs when at the command line.…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now