English 中文(简体)
如何将当地Gite存放处推向另一个计算机?
原标题:How to push a local Git repository to another computer?
  • 时间:2010-05-22 12:16:25
  •  标签:
  • git
  • git-push

我的手提电脑上有一个当地Gite存放处。 我谨将其推向我的台式。

我如何能够这样做?

最佳回答
问题回答

在此,我写道,只是这样做。 文字处理所有我通常采用的新陈词典。

  1. creates .gitignore file
  2. initializes .git
  3. creates the bare git repo on the server
  4. sets up the local git repo to push to that remote repo

http://gist.github.com/410050

无疑,你必须加以修改,以适应你的任何 set,特别是如果你重新处理Windows Computer/desktop。

全文如下:

#!/bin/bash
# Create Git Repository
# created by Jim Kubicek, 2009
# jimkubicek@gmail.com
# http://jimkubicek.com

# DESCRIPTION
# Create remote git repository from existing project
# this script needs to be run from within the project directory

# This script has been created on OS X, so YMMV

#######
# Parameters
REPLOGIN=#Login name
REPADDRESS=#Repo address
REPLOCATION=/Users/Shared/Development #Repo location

# The repo name defaults to the name of the current directory.
# This regex will accept foldernames with letters and a period.
# You ll have to edit it if you ve got anything else in your folder names.
REPNAME=`pwd | egrep -o "/[a-zA-Z]+$" | egrep -o "[a-zA-Z.]+"`


# If you have standard files/directories to be ignored
# add them here
echo "Creating .gitignore"
echo  build/  >> .gitignore # The build directory should be ignored for Xcode projs
echo  .DS_Store  >> .gitignore # A good idea on OS X

# Create the git repo
echo "Initializing the repo"
git init
git add .
git commit -m "Initial commit"

# Copy the repo to the server
echo "Copying the git repo to the server $REPADDRESS"
TEMPREP="$REPNAME.git"
git clone --bare .git $TEMPREP
scp -r $TEMPREP $REPLOGIN@$REPADDRESS:$REPLOCATION/
rm -rf $TEMPREP

# Set up the origin for the project
echo "Linking current repository to remote repository"
git remote add origin $REPLOGIN@$REPADDRESS:$REPLOCATION/$REPNAME.git/




相关问题
git confusion - cloning a repo is returning a past version

Im having some confusion with my git usage. I cloned a repo from one comp to the other, and the new clone is the state of the original that was active some time ago. So its cloning a past version. ...

Appropriate strategy for tagging and hotfixing with git

I was wondering if the strategy I m using for tagging and hotfixing tags (which then I use for deploying rails applications) with git is appropriate. For tagging I just tag a commit of the master ...

Tips on upgrading CVS to git/hg?

We still use CVS, I use git and hg for my personal use though I m still a novice at both, but I realize they re much more modern and better, faster, distributed, etc. It s just everyone is so ...

Using Git in a TFS shop

Using Git at home has spoiled me - I now find using TFS at work to be a bit of a drag and want to explore the possibility of using Git locally and syncing somehow with TFS. I figure there are a few ...

热门标签