ruby-on-rails - 运行命令 'git remote' 以部署 Ruby on Rails 应用程序时出现问题

标签 ruby-on-rails ruby-on-rails-3 git deployment

我正在尝试部署我的 Ruby on Rails 3.0.9 应用程序,因此我设置了以下内容:

git remote add origin ssh://user@host/~/git/application_name.git

当我运行命令时

git push origin master

我收到此错误(注意:“Unkn”字符串在输出时被“剪切”):

fatal: protocol error: bad line length character: Unkn

所以,读完this git faq ,我运行以下命令:

git remote rm origin
git remote add origin ssh user@host/~/git/application_name.git

现在,当我运行命令时

 git push origin master

我收到这个错误:

fatal: 'ssh' does not appear to be a git repository

正如 git faq 文档中所写,我也尝试运行命令

ssh user@host echo testing commands

但我得到以下信息

Unknown command 'echo testing commands'

问题是什么?我该如何解决?


我还尝试了以下方法:

 1. git remote add origin user@host:~/git/application_name.git
 2. git remote add origin user@host/~/git/application_name.git

我分别得到以下错误:

 # The terminal asks me to insert the server password
 1. fatal: protocol error: bad line length character: Unkn

 # The terminal does not asks me to insert the server password
 2. fatal: 'user@host:~/git/application_name.git' does not appear to be a git repository

更新

~/.bashrc

# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples

# If not running interactively, don't do anything
[ -z "$PS1" ] && return

# don't put duplicate lines in the history. See bash(1) for more options
# ... or force ignoredups and ignorespace
HISTCONTROL=ignoredups:ignorespace

# append to the history file, don't overwrite it
shopt -s histappend

# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000

# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize

# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"

# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
    debian_chroot=$(cat /etc/debian_chroot)
fi

# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
    xterm-color) color_prompt=yes;;
esac

# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes

if [ -n "$force_color_prompt" ]; then
    if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
        # We have color support; assume it's compliant with Ecma-48
        # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
        # a case would tend to support setf rather than setaf.)
        color_prompt=yes
    else
        color_prompt=
    fi
fi

if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\0
33[01;34m\]\w\[\033[00m\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt

# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
    ;;
*)
    ;;
esac

# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dirco
lors -b)"
    alias ls='ls --color=auto'
    #alias dir='dir --color=auto'
    #alias vdir='vdir --color=auto'

    alias grep='grep --color=auto'
    alias fgrep='fgrep --color=auto'
    alias egrep='egrep --color=auto'
fi

# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'

# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi

# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
#if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
#    . /etc/bash_completion
#fi

~/.profile

# ~/.profile: executed by Bourne-compatible login shells.

if [ "$BASH" ]; then
  if [ -f ~/.bashrc ]; then
    . ~/.bashrc
  fi
fi

mesg n

~/.bash_profile

# empty!!!

最佳答案

你的 git remote 语法有误。对于 SSH 可访问的远程存储库,存储库的格式应为 user@host:path/repo.git,即在您的情况下:

git remote add origin user@host:~/git/application_name.git

关于ruby-on-rails - 运行命令 'git remote' 以部署 Ruby on Rails 应用程序时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6894536/

相关文章:

ruby-on-rails - 处理不兼容的字符编码 : UTF-8 and ASCII-8BIT

ruby-on-rails - Mailcatcher 无法在临时服务器中工作

ruby-on-rails - 作业加载失败 : `@' is not allowed as an instance variable name

mysql - 以 Ruby on Rails 3 中 2 个表的形式显示数据

ruby-on-rails-3 - 如何更改 Rack 离线的默认行为

Git merge 不会第二次 merge 文件

git - Git 和 GitHub Desktop 是完全独立的应用吗?

ruby-on-rails - Cucumber/Capybara -- 如何获取当前执行的主机和端口

ruby-on-rails - rails : pass has_many or belongs_to attribute in 'generate' command

Git svn fetch、rebase、reset 和 dcommit 函数在一个 svn 分支上全部挂起且没有错误