Solved

Git push without pull?

Posted on 2014-04-04
2
2,647 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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

825 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