top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration
Print Preview

How to add my local repository files to a server repository in Git

+2 votes

I have a local repository and want to change the master branch to a server git. (I just don't want to delete all files in repository and then clone the server files)How to do that? I guess I have to fetch server data into local directory, merge an push it. Can someone please explain me how to do?

posted Sep 13, 2013 by Garima Jain

Looking for an answer?  Promote on:
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button
Do you want to copy the branch master state of your remote repository to your local branch master? If yes, you can do it using the command: git reset --hard origin/master, With that you will lose all changes that are in your local branch but not in your remote branch.
You are right, i want  to copy the branch master state of my remote repository to my local branch master and i I think the command is what Im looking for.  
But what to do before? Must i go into the local branch and then fetch from server?For example I have a local repository in directory "mylocal".  (It was a cvs ckecked out directory, now I init a git repository in it) cd mylocalgit remote add myserver user@myserver:/var/www/server_gitfetch myservergit reset --hard origin/master
Is it correct?
You are correct. Just clean every file in your mylocal directory before using the commands.

Similar Questions
+1 vote

How to configure a read-only copy of a remote Git repository on a local server in bare mode and automatically synchronize its contents.

I need to configure a mirror of the repository hosted at another location and the mirrored repository should automatically perform syncing of code at regular intervals.

0 votes

I have tried some methods introduced in the network, but always failed. Some big files committed by me to a very old branch then the files deleted and new branches were continuously created. Now the checkout directory has grown to about 80 megabytes.

What's the right way to permanently erase those garbage big files?

+1 vote

There's a challenge that i'm currently facing after migration from WINCVS to GIT. The problem here is I need to pull/fetch a specific branch (and NOT clone the entire repository) from the repository to a particular location on the AIX server.

Earlier while using WINCVS this functionality was achievable using JCVSExport package as we could just checkout a particular branch and fetch the package on to the server location.
WINCVS Command : java JCVSExport -h -u abcde -p xxxxxx -d /abcd/cvs/testing -c "$REPOSITORY" -m "$PACKAGE"

I am not able to achieve the same functionality using GIT. I DO NOT want to clone the entire repository on the AIX server instead I just want to fetch/pull a specific branch contents on the server. Can someone please help me out with the solution or any possible way with which I can achieve the same functionality.

Useful Links with Similar Problem
Contact Us
+91 9880187415
#470/147, 3rd Floor, 5th Main,
HSR Layout Sector 7,
Bangalore - 560102,
Karnataka INDIA.