Git receive pack not found windows

Wondering how to fix this problem in Windows ? When i try and use the command "git push origin master" I get git-receive-pack: command not found Any idea how I can fix this in windows ? The...

Wondering how to fix this problem in Windows ?

When i try and use the command «git push origin master» I get

git-receive-pack: command not found

Any idea how I can fix this in windows ?

The path to GIT is in c:/program files/Git/Bin/ but unsure how to set this ?

Thx

Edit: doing

git—exec-path
c:Program FilesGit/libexec/git-core

Now how to setup this somewhere?

asked Sep 27, 2009 at 14:49

10

You need to add the bin folder path where git was installed to the PATHS of the Windows System Environment variables. But if you have installed git using a 64-bit installer the path is different:

C:Program FilesGitmingw64bin

notice the sub path «mingw64».

Pengyy's user avatar

Pengyy

36.6k15 gold badges82 silver badges73 bronze badges

answered Apr 4, 2018 at 8:49

johnsabre's user avatar

johnsabrejohnsabre

3452 silver badges7 bronze badges

From Git FAQ:

Basically the problem is that ‘git-receive-pack’ is not in the default $PATH on the remote end.

You can see the problem using a DOS window:

set PATH

(display the path)

type

set PATH=%PATH%;"c:/program files/Git/Bin"
git push origin master

If that solves the problem, you will be better off adding that path in your user environment variables (see this superuser question for instance)


Or a bash Git shell:

$ export PATH=$PATH:"/c/Program Files/Git/bin"
$ git push origin master

Check also your .bashrc in your $HOME path (‘echo $HOME‘ within a bash session; add the export line in it, or simply ‘~/.bashrc‘)


Note: a classic msysgit installation should have taken care of those path.

Community's user avatar

answered Sep 27, 2009 at 15:14

VonC's user avatar

VonCVonC

1.2m508 gold badges4244 silver badges5066 bronze badges

4

I had a similar problem when trying to execute a git pull from another Win-7 machine. Here’s what I did:

  • In order to interact with remote repositories via Git, the Git directories need to be added to the REMOTE machine’s Windows PATH environmental variable (this should be done for any Windows machine running Git and needing to clone, push, or pull)
  • Git directories to add (so far):

    ..gitbin,
    ..gitlibexecgit-core,
    ..gitcmd

  • To modify the Windows-7 path, use the following:

    Click Start, then right-click on «Computer» and select «Properties»,
    On the left panel, select «Advanced system settings»,
    In the System Properties dialog, click on the «Environmental Variables…» button,
    Select «Path» from the «System variables list», and click the «Edit» button

Add the needed paths to the end of the existing Path string using a semi-colon as the delimiter. Note: the path needs to be specified from the disk root (e.g. C:).

answered Aug 7, 2012 at 0:04

DTS's user avatar

DTSDTS

511 silver badge1 bronze badge

I had this problem when I mistakenly tried to git clone a repo that was actually a Mercurial repo. Someone else created the project and I’d never used Mercurial before.

Felt like an idiot, but I couldn’t find any answers on SO that fixed it. Whoops!

answered Feb 19, 2014 at 17:51

Kyle Carlson's user avatar

Kyle CarlsonKyle Carlson

7,8375 gold badges34 silver badges42 bronze badges

0

I’ve tried many things before creating this topic. Since, many seem to have this problem. So here’s the thing. I simply can’t push to git-hub. I know what you might be thinking, that I haven’t added the bin directory to my PATH. But, I have, so before you mark this as a duplicate, please consider that I’ve looked at these:

http://stackoverflow.com/questions/12186040/git-receive-pack-stops-with-0000
http://stackoverflow.com/questions/225291/git-upload-pack-command-not-found-how-to-fix-this-correctly
http://stackoverflow.com/questions/15323268/git-upload-pack-not-found
http://stackoverflow.com/questions/15777797/git-push-error-git-receive-pack
http://stackoverflow.com/questions/1483722/git-receive-pack-command-not-found-in-windows

I’ve even downloaded the github for windows app, and it still gives me the same error. So, what do you do, when you get this error, on a windows machine, I’, running Git 1.8.1. This is the error:

https://github.com/random12345@gmail.com/random.git/info/refs?service=git-receive-pack not found: did you run git update-server-info on the server?

EDIT 1:
Not showing my real email, I’m just showing you the gist of the message.

When you run git push the send-pack part of the protocol is running on your, local side, and it connects to the receive-pack part running on the remote side.

So let’s say you run git push, where your remote origin repo is configured to use ssh and is mapped to server.com. Git uses send-pack to initiate a connection over ssh to the server extracted from the remote URL *:

$ ssh server.com "git-receive-pack /path/to/repo.git"


* When the repository was previously cloned or added as git remote add origin ssh://server.com/path/to/repo.git

Note that the quoted command is run by ssh on the remote server, and it is possible that git-receive-pack could not be located there. You can test for this yourself as follows:

$ ssh server.com "type -p git-receive-pack" || echo "git-receive-pack not found"

If indeed the git-receive-pack command could not be located on the remote — for instance, because it is not in the PATH of your remote login shell, you can tell git push where it should look for it by running:

$ git push --receive-pack=/server/com/full/path/to/git-receive-pack

And you can save typing that every time you push by telling git to remember to use the explicit path via the config:

$ git config remote.origin.receivepack /server/explicit/path/to/git-receive-pack

I have been trying to set up a simple SSH server on my PC to use with Git. The idea is to have a git repo on my PC and push any work I do from my laptop when outside. Both machines run Windows 8.

I tried a couple of SSH server solutions, but I finally decided to go with Bitvise SSH server. I can SSH normally from my laptop using public key authentication.

When I try to use Git though, I get an error git-upload-pack: command not found. I seached around and ended up on a post from stack overflow which basically said that the PATH might no be properly set for non-logic users.

I actually executed the command matt said, and it turns out that cgitbin is not part of the PATH, even though I have set it as a system variable. As far as I can see, editing the system enviornmental variables in Windows does not affect this PATH. Any ideas how I need to set this properly?

Bitvise’s settings for the virtual user group I use are the following:
enter image description here

Thanks!

Community's user avatar

asked Nov 9, 2014 at 16:58

Dimitrios K.'s user avatar

Today, I’ve had the same experience. I was trying to setup a Git server on Windows 7, with the Bitvise SSH server. After having setup the SSH server and installing Git, when I tried to pull from the origin, I received git-upload-pack: command not found and when trying to push to the origin I received git-receive-pack: command not found.

Obviously, this is server side problem. The server cannot execute git-upload-pack and git-receive-pack. What you will need to do:

To use these Git commands, you should add them to your PATH variable. Follow these steps:

  1. Find the path to your Git install directory (On my machine it’s C:InstallsGit)
  2. On your desktop/start menu: right-click My Computer > Properties
  3. Click Advanced System settings
  4. Open the tab Advanced
  5. Click the button Environment variables
  6. Under System variables find Path and click Edit...
  7. Append ;C:InstallsGitlibexecgit-core in the lower box.
  8. Click OK, OK, OK, and close everything.

Now, git-upload-pack and git-receive-pack is available in the command line. This is how I fixed this exact problem. Hope it works for you.

answered Dec 18, 2014 at 11:56

Koen's user avatar

KoenKoen

1314 bronze badges

When I try to use Git though, I get an error git-upload-pack: command not found. I seached around and ended up on a post from stack overflow which basically said that the PATH might no be properly set for non-logic users.

This PATH is not the PATH in the system environment. It’s the path for user@sshserver.

You can use ls or dir which depend on what terminal you provide for the ssh client to find The PATH for user@sshserver.

And you need to change the permission for the user on that PATH on server side. You can also refer this link.

Stephen Rauch's user avatar

answered Apr 7, 2017 at 3:23

Shihe Zhang's user avatar

HTTPS cloning errors

There are a few common errors when using HTTPS with Git. These errors usually indicate you have an old version of Git, or you don’t have access to the repository.

Here’s an example of an HTTPS error you might receive:

> error: The requested URL returned error: 401 while accessing
> https://github.com/USER/REPO.git/info/refs?service=git-receive-pack
> fatal: HTTP request failed
> Error: The requested URL returned error: 403 while accessing
> https://github.com/USER/REPO.git/info/refs
> fatal: HTTP request failed
> Error: https://github.com/USER/REPO.git/info/refs not found: did you run git
> update-server-info on the server?

Check your Git version

There’s no minimum Git version necessary to interact with GitHub, but we’ve found version 1.7.10 to be a comfortable stable version that’s available on many platforms. You can always download the latest version on the Git website.

Ensure the remote is correct

The repository you’re trying to fetch must exist on GitHub.com, and the URL is case-sensitive.

You can find the URL of the local repository by opening the command line and
typing git remote -v:

$ git remote -v
# View existing remotes
> origin  https://github.com/ghost/reactivecocoa.git (fetch)
> origin  https://github.com/ghost/reactivecocoa.git (push)

$ git remote set-url origin https://github.com/ghost/ReactiveCocoa.git
# Change the 'origin' remote's URL

$ git remote -v
# Verify new remote URL
> origin  https://github.com/ghost/ReactiveCocoa.git (fetch)
> origin  https://github.com/ghost/ReactiveCocoa.git (push)

Alternatively, you can change the URL through our
GitHub Desktop application.

Provide an access token

To access GitHub, you must authenticate with a personal access token instead of your password. For more information, see «Creating a personal access token.»

If you are accessing an organization that uses SAML SSO and you are using a personal access token (classic), you must also authorize your personal access token to access the organization before you authenticate. For more information, see «About authentication with SAML single sign-on» and «Authorizing a personal access token for use with SAML single sign-on.»

Check your permissions

When prompted for a username and password, make sure you use an account that has access to the repository.

Tip: If you don’t want to enter your credentials every time you interact with the remote repository, you can turn on credential caching. If you are already using credential caching, please make sure that your computer has the correct credentials cached. Incorrect or out of date credentials will cause authentication to fail.

Use SSH instead

If you’ve previously set up SSH keys, you can use the SSH clone URL instead of HTTPS. For more information, see «About remote repositories.»

Error: Repository not found

If you see this error when cloning a repository, it means that the repository does not exist or you do not have permission to access it. There are a few solutions to this error, depending on the cause.

Check your spelling

Typos happen, and repository names are case-sensitive. If you try to clone git@github.com:user/repo.git, but the repository is really named User/Repo you will receive this error.

To avoid this error, when cloning, always copy and paste the clone URL from the repository’s page. For more information, see «Cloning a repository.»

To update the remote on an existing repository, see «Managing remote repositories».

Checking your permissions

If you are trying to clone a private repository but do not have permission to view the repository, you will receive this error.

Make sure that you have access to the repository in one of these ways:

  • The owner of the repository
  • A collaborator on the repository
  • A member of a team that has access to the repository (if the repository belongs to an organization)

Check your SSH access

In rare circumstances, you may not have the proper SSH access to a repository.

You should ensure that the SSH key you are using is attached to your personal account on GitHub. You can check this by typing
the following into the command line:

$ ssh -T git@github.com
> Hi USERNAME! You've successfully authenticated, but GitHub does not
> provide shell access.

If the repository belongs to an organization and you’re using an SSH key generated by an OAuth App, OAuth App access may have been restricted by an organization owner. For more information, see «About OAuth App access restrictions.»

For more information, see Adding a new SSH key to your GitHub account.

Check that the repository really exists

If all else fails, make sure that the repository really exists on GitHub.com!
If you’re trying to push to a repository that doesn’t exist, you’ll get this error.

Error: Remote HEAD refers to nonexistent ref, unable to checkout

This error occurs if the default branch of a repository has been deleted on GitHub.com.

Detecting this error is simple; Git will warn you when you try to clone the repository:

$ git clone https://github.com/USER/REPO.git
# Clone a repo
> Cloning into 'repo'...
> remote: Counting objects: 66179, done.
> remote: Compressing objects: 100% (15587/15587), done.
> remote: Total 66179 (delta 46985), reused 65596 (delta 46402)
> Receiving objects: 100% (66179/66179), 51.66 MiB | 667 KiB/s, done.
> Resolving deltas: 100% (46985/46985), done.
> warning: remote HEAD refers to nonexistent ref, unable to checkout.

To fix the error, you’ll need to be an administrator of the repository on GitHub.com.
You’ll want to change the default branch of the repository.

After that, you can get a list of all the available branches from the command line:

$ git branch -a
# Lists ALL the branches
>   remotes/origin/awesome
>   remotes/origin/more-work
>   remotes/origin/new-main

Then, you can just switch to your new branch:

$ git checkout new-main
# Create and checkout a tracking branch
> Branch new-main set up to track remote branch new-main from origin.
> Switched to a new branch 'new-main'

I have been using git to keep two copies of my project in sync, one is my local box, the other the test server.
This is an issue which occurs when I log onto our remote development server using ssh;

git clone [email protected]:/home/chris/myproject
Initialized empty Git repository in /tmp/myproject/.git/
Password:
bash: git-upload-pack: command not found
fatal: The remote end hung up unexpectedly
fetch-pack from '[email protected]:/home/chris/myproject' failed.

(the file-names have been changed to protect the guilty… !)

Both boxes run Solaris 10 AMD. I have done some digging, if I add --upload-pack=$(which git-upload-pack) the command works, (and proves that $PATH contains the path to ‘git-upload-pack’ as per the RTFM solution) but this is really annoying, plus ‘git push’ doesn’t work, because I don’t think there is a --unpack= option.

Incidentally, all the git commands work fine from my local box, it is the same version of the software (1.5.4.2), installed on the same NFS mount at /usr/local/bin.

Can anybody help?

15 Answers

Make sure git-upload-pack is on the path from a non-login shell. (On my machine it’s in /usr/bin).

To see what your path looks like on the remote machine from a non-login shell, try this:

ssh [email protected] echo $PATH

(That works in Bash, Zsh, and tcsh, and probably other shells too.)

If the path it gives back doesn’t include the directory that has git-upload-pack, you need to fix it by setting it in .bashrc (for Bash), .zshenv (for Zsh), .cshrc (for tcsh) or equivalent for your shell.

You will need to make this change on the remote machine.

If you’re not sure which path you need to add to your remote PATH, you can find it with this command (you need to run this on the remote machine):

which git-upload-pack

On my machine that prints /usr/bin/git-upload-pack. So in this case, /usr/bin is the path you need to make sure is in your remote non-login shell PATH.

You can also use the «-u» option to specify the path. I find this helpful on machines where my .bashrc doesn’t get sourced in non-interactive sessions. For example,

git clone -u /home/you/bin/git-upload-pack [email protected]:code

Building on Brian’s answer, the upload-pack path can be set permanently by running the following commands after cloning, which eliminates the need for --upload-pack on subsequent pull/fetch requests. Similarly, setting receive-pack eliminates the need for --receive-pack on push requests.

git config remote.origin.uploadpack /path/to/git-upload-pack
git config remote.origin.receivepack /path/to/git-receive-pack

These two commands are equivalent to adding the following lines to a repo’s .git/config.

[remote "origin"]
    uploadpack = /path/to/git-upload-pack
    receivepack = /path/to/git-receive-pack

Frequent users of clone -u may be interested in the following aliases. myclone should be self-explanatory. myfetch/mypull/mypush can be used on repos whose config hasn’t been modified as described above by replacing git push with git mypush, and so on.

[alias]
    myclone = clone --upload-pack /path/to/git-upload-pack
    myfetch = fetch --upload-pack /path/to/git-upload-pack
    mypull  = pull --upload-pack /path/to/git-upload-pack
    mypush  = push --receive-pack /path/to/git-receive-pack

I found and used (successfully) this fix:

# Fix it with symlinks in /usr/bin
$ cd /usr/bin/
$ sudo ln -s /[path/to/git]/bin/git* .

Thanks to Paul Johnston.

Mac OS X and some other Unixes at least have the user path compiled into sshd for security reasons so those of us that install git as /usr/local/git/{bin,lib,…} can run into trouble as the git executables are not in the precompiled path. To override this I prefer to edit my /etc/sshd_config changing:

#PermitUserEnvironment no

to

PermitUserEnvironment yes

and then create ~/.ssh/environment files as needed. My git users have the following in their ~/.ssh/environment file:

PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/git/bin

Note variable expansion does not occur when the ~/.ssh/environment file is read so:

PATH=$PATH:/usr/local/git/bin

will not work.

Matt’s solution didn’t work for me on OS X, but Paul’s did.

The short version from Paul’s link is:

Created /usr/local/bin/ssh_session with the following text:

#!/bin/bash
export SSH_SESSION=1
if [ -z "$SSH_ORIGINAL_COMMAND" ] ; then
    export SSH_LOGIN=1
    exec login -fp "$USER"
else
    export SSH_LOGIN=
    [ -r /etc/profile ] && source /etc/profile
    [ -r ~/.profile ] && source ~/.profile
    eval exec "$SSH_ORIGINAL_COMMAND"
fi

Execute:

chmod +x /usr/local/bin/ssh_session

Add the following to /etc/sshd_config:

ForceCommand /usr/local/bin/ssh_session

For bash, it needs to be put into .bashrc not .bash_profile (.bash_profile is also only for login shells).

I got these errors with the MsysGit version.

After following all advice I could find here and elsewhere, I ended up:

installing the Cygwin version of Git

on the server (Win XP with Cygwin SSHD), this finally fixed it.

I still use the MsysGit version client side

..in fact, its the only way it works
for me, since I get POSIX errors with
the Cygwin Git pull from that same
sshd server

I suspect some work is still needed this side of Git use..
(ssh+ease of pull/push in Windows)

Like Johan pointed out many times its .bashrc that’s needed:

ln -s .bash_profile .bashrc

You must add the

export PATH=/opt/git/bin:$PATH

before this line in the .bashrc:

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

Otherwise all export statements will not be executed (see here).

My case is on Win 10 with GIT bash and I don’t have a GIT under standard location. Instead I have git under /app/local/bin.
I used the commands provided by @Garrett but need to change the path to start with double /:

git config remote.origin.uploadpack //path/to/git-upload-pack
git config remote.origin.receivepack //path/to/git-receive-pack

Otherwise the GIT will add your Windows GIT path in front.

For zsh you need to put it in this file: ~/.zshenv

For example, on OS X using the git-core package from MacPorts:

$ echo ‘export PATH=/opt/local/sbin:/opt/local/bin:$PATH’ > ~/.zshenv

I have been having issues connecting to a Gitolite repo using SSH from Windows and it turned out that my problem was PLINK! It kept asking me for a password, but the ssh [email protected][host] would return the repo list fine.

Check your environment variable: GIT_SSH. If it is set to Plink, then try it without any value («set GIT_SSH=») and see if that works.

Add the location of your git-upload-pack to the remote git user’s .bashrc file.

It may be as simple as installing git on the remote host (like it was in my case).

sudo apt-get install git

Or equivalent for other package management systems.

When pulling from a remote git repository located on shared hosting you will get the “git-upload-pack: command not found” error. A similar error occurs with the git-receive-pack when doing a push as well. This occurs when git is installed locally (in your home directory), and not system wide because git cannot locate these binaries.

Normally this can be fixed by setting the $PATH environment variable to include the correct path to these binaries on the remote server. Unfortunately it will not work in this case as .bashrc is not sourced since the command is invoked in non-interactive mode via ssh.

There are 2 solutions to this problem.

The first solution is to explicitly include the path to the binaries when pushing or pulling from your local repository.

$ git pull --upload-pack /path/to/git/git-upload-pack$ git push --receive-pack /path/to/git/git-receive-pack

The second solution involves adding the path to your git-upload-path and git-recieve-path in your local .git/config file under [remote “origin”]. This is the easiest method as you only have to make this change once.

[remote "origin"]
url = <repo address>
fetch = +refs/heads/*:refs/remotes/origin/*
uploadpack = <path to git-upload-pack>
receivepack = <path to git-receive-pack>

При попытке отредактировать этот старый пост слетело всё форматирование. Может быть я его когда-нибудь исправлю.

Я потратил несколько месяцев на борьбу с глюками Git-svn и обдумывание разных вариантов, прежде чем пришёл к этому методу организации рабочего процесса с сайтом — простому, гибкому и удобному в работе.

Основные преимущества:

  • Делая push из удалённой копии мы автоматически обновляем live-копию сайта
  • Правки файлов на сервере не будут разрушать историю коммитов
  • Простота, не нужны особые правила выполнения коммитов
  • Можно применить к уже запущенному сайту, без повторного деплоя или перемещения файлов

Обзор

Главная идея системы — создение на сервере двух репозиториев: пустого bare-репозитория и обычного репозитория с рабочей копией сайта. Эта пара связана парой простых хуков, которые автоматизируют push и pull изменений.

Схема работы

Итак, два репозитория:

  • Hub — bare-репозиторий. Все репозитории разработчиков клонируются именно от него.
  • Prime — обычный репозиторий. Сайт запускается из рабочего каталога этого репозитория.

Работа с двумя репозиториями простая и очень гибкая. Удалённые копии, имеющие ssh-доступ могут легко обновлять live-версию сайта просто выполнив push в Hub-репозиторий. Любые изменения, выполненные в live-версии на сервере мгновенно вливаются в Hub при коммите. В общем, всё работает очень просто — и неважно, где делаются изменения.

Небольшие приготовления перед стартом

Естественно, в первую очередь нужно, что бы Git был установлен на сервере и на всех компах разработчиков. Если на вашем shared-хостинге не установлен Git — вы очень легко можете это исправить (en).

Если вы первый раз работаете с Git на своём сервере, не забудьте указать глобальные настройки. Я указываю особое значения для user.name, чтобы потом видеть в истории проекта изменения, выполненные на сервере:

$ git config --global user.name "Джо, фигачу на сервере"

Поехали!

В первую очередь создадим новый git-репозиторий в live-каталоге нашего сайта, а затем добавим и зафиксируем все файлы сайта. Это будет Prime-репозиторий и рабочая копия. Даже если уже есть история проекта в других местах, содержимое сайта будет базовой точкой, в которую потом будут слиты все остальные копии.

$ cd ~/www
$ git init
$ git add .
$ git commit -m "Импорт всех существующих файлов сайта"

Поскольку мы сделали инициализацию репозитория в рабочей копии – нет нужды отключать сайт на обслуживание и повторно выкладывать все файлы, Git просто содаст репозиторий из имеющихся файлов.

Теперь, когда наш сайт уже находится в Git, создадим bare-репозиторий где-нибудь вне рабочего каталога сайта.

$ cd
$ mkdir site_hub.git
$ cd site_hub.git
$ git --bare init
Initialized empty Git repository in /home/joe/site_hub.git

Ура! Снова вернёмся в рабочий каталог сайта и добавим Hub как удалённый репозиторий, а затем вольём в Hub содержимое ветки master из Prime-репозитория.

$ cd ~/www
$ git remote add hub ~/site_hub.git
$ git remote show hub
* remote hub
 URL: /home/joe/site_hub.git
$ git push hub master

Хуки

Как я уже упоминал в начале, Hub и Prime синхронизируются между собой, используя два простых скрипта.

Одно из основных правил при работе с Git — никогда не делайте push в репозтирий, у которого есть рабочая копия. Мы следуем этому правилу и создали репозиторий «Hub». Вместо того, чтобы делать push из Hub, который никак не повлияет на рабочую копию, мы будем использовать хук, который заставит Prime выполнить pull из Hub-репозитория.

Post-update — в Hub-репозитории

Как только в Hub поступит новая порция изменений, сразу будет выполнен этот скрипт. Мы переходим в рабочий каталог Prime-репозитория, и вытягиваем измениния из Hub’а. Проталкивание изменений (push) не изменяет состояния рабочего каталога репозитория, поэтому и нужно делать pull, находясь в рабочем каталоге.

#!/bin/sh

echo
echo

"**** Вытягиваем изменения в Prime [Hub's post-update hook]"
echo

cd $HOME/www || exit
unset GIT_DIR
git pull hub master

exec git update-server-info

Post-commit — в Prime-репозитори

Этот скрипт запускается после каждого коммита в Prime-репозитории и проталкивает изменения в Hub. В идеальном мире, конечно, мы вообще никогда ничего не будем править прямо на сервере. Но в нашем несовершенном мире возможно всё, что угодно, поэтому давайте автоматизируем процесс проталкивания изменений, чтобы не разрушать историю проекта и избежать возможных конфликтов.

#!/bin/sh

echo
echo

"**** pushing changes to Hub [Prime's post-commit hook]"
echo

git push hub

Итак, используя этот хук, мы сразу же получаем в Hub-репозитория все изменения, выполненные в master-ветке Prime-резпозитория. Прочие ветки также можно клонировать, но они не будут влиять на сайт. Поскольку все удалённые копии получают доступ через SSH-адрес к Hub, то выполнить push и запустить обновление сайта напрямую могут только пользователи, имеющие прямой доступ к shell’у.

Конфликты

«Положить» сайт при такой системе синхронизации двух репозиториев очень сложно. Каждое изменение, сделанное в Prime автоматически попадает в Hub и все конфликты будут сразу видны при попытке выполнить push из клонов репозитория.

Но всё же есть несколько ситуаций, при которых состояние Prime может отличаться от Hub’а, и для исправления ситуации потребуется выполнить несколько дополнительных телодвижений. Если мы что-то правим на Prime и не зафиксировали изменения, а в этот момент сработает post-update в Hub, то все завершится ошибкой с сообщением «Entry ‘foo’ not uptodate. Cannot merge.». Фиксация изменений в рабочем каталоге Prime позволит зачистить его состояние, и post-update хук сможет соединить все неотправленные изменения.

Также я обнаружил, что если конфликт возникает вследствие того, что изменения в Prime не могут быть объединены с Hub’ом, то наилучшим решением будет протолкнуть текущее состояние Prime’а в новую ветку на Hub. Эта команда, выполненная из рабочего каталога Prime создаст удалённую ветку «fixme», основанную на текущем стоянии Prime-репозитория.

$ git push hub master:refs/heads/fixme

Как только изменения окажутся в Hub’е, мы сможем получить ветку в любом из клонов, разрешить конфликт и смержить ветки. Попытка разрешить конфликт прямо на сервере почти наверняка приведёт к проблемам в работе сайте из-за появления маркеров конфликтных областей.

Держим всё в чистоте

Каталог .git Prime-репозитория находится в корневом каталоге сайта, и, верояно, доступен для публичного доступа. Чтобы никто не смог сунуть свой нос, куда не следует, добавьте эти строки в файл .htaccess верхнего уровня:

# deny access to the top-level git repository:
RewriteEngine On
RewriteRule .git - [F,L]

Прим. переводчика: есть и другие способы закрыть доступ к каталогу на сервере.

Прочие проблемы

Если при попытке выполнить push в репозиторий на сервере вы видите эту ошибку:

git-receive-pack: command not found
fatal: The remote end hung up unexpectedly

В этом случае просто добавьте export PATH=${PATH}:~/bin в ваш файл .bashrc, лежащий на сервере.

Skip to content

When doing a push to master I was getting

bash: git-upload-pack: command not found
bash: git-receive-pack: command not found

For me my server was not recognizing the git command. I had to add the server paths to my local git config

receivepack = /home3/<myusername>/local/git-1.6.4/git-receive-pack
uploadpack = /home3/<myusername>/local/git-1.6.4/git-upload-pack

where the config file is in the .git directory of my project on local. This line is under the entry for the remote I had set up called ‘origin’ (use the path on the server where the git install is located and make sure git-receive-pack is in there on the server).

BUT,I think the following is be the better solution. Editing the .bashrc worked like a charm. I added the following line to my .bashrc file (look in /etc or you home/ directory if on a shared server) and things worked swimmingly.

export PATH=”$PATH:/home3/<myusername>/local/git-1.6.4″

replace /home3/… with whatever the path to your git install may be.

I’m still not clear on why the path would be different for a bash ssh command, and a client sending a request over ssh to the server. It seems as if even though my server environment variable $PATH includes the path to the git install, the $PATH variables does not include that path if the git commands are invoked over a remote ssh request (like my eclipse working with git). But if I was logged in on a bash shell, the git commands worked great, with no ‘command not found’ errors. Make sure when you install git, that you understand how to make your server recognize the git executable commands, both from the bash and also from remote requests. I’m still unclear on the difference between 1) editing the $PATH environment variable to include your git directory 2) Editing the .bashrc with the export $PATH setting. 3) Making symbolic links from the bin folder to your git install.

See http://stackoverflow.com/questions/225291/git-upload-pack-command-not-found-how-to-fix-this-correctly

Recently we planned to use git version control system. So I tried to setup the git server in the server machine, and everything went  well from the server side. While making local copy in the the local machine we got the below error.

$ git clone ssh://remotehost:/git-path/git/root.git

Cloning into root…

Password:

bash: git-upload-pack: command not found

fatal: The remote end hung up unexpectedly


The reason for this is, it is not finding the path for the git-upload-pack. you need to specify the path manually. For that just use -u option for the git clone command and specify the path of git-upload-pack path in the server.

$ git clone -u /usr/local/git/bin/git-upload-pack ssh://remotehost:/git-path/git/root.git
Cloning into ‘root’…
Password:
remote: Counting objects: 408, done.
remote: Compressing objects: 100% (330/330), done.
remote: Total 408 (delta 90), reused 379 (delta 69)
Receiving objects: 100% (408/408), 27.00 MiB | 47.22 MiB/s, done.
Resolving deltas: 100% (90/90), done.

To get the path of the git-upload-pack in the server, login to the server and run which git-upload-pack command as shown below.

$ which git-upload-pack
/usr/local/git/bin/git-upload-pack

when you do git pull or git push , you may get this error.

$ git pull
bash: git-upload-pack: command not found
fatal: The remote end hung up unexpectedly

$git push
bash: git-receive-pack: command not found
fatal: The remote end hung up unexpectedly


To solve that problem, you can either run the below commands or  modify the config file in .git directory.

$ git config remote.origin.uploadpack /usr/local/git/bin/git-upload-pack

$ git config remote.origin.receivepack /usr/local/git/bin/git-receive-pack

or you can edit the .git/config file and add the content in the below form.

[remote «origin»]

        fetch = +refs/heads/*:refs/remotes/origin/*

        url = remote_host:/path/git/root.git

        uploadpack = /usr/local/git/bin/git-upload-pack

        receivepack = /usr/local/git/bin/git-receive-pack

Then you can able to clone the git repository, you can able to pull/push the code from/to the remote server. 

Like this post? Please share to your friends:
  • Git for windows что это за программа
  • Git credential manager for windows что это
  • Gigabyte h510m h установка windows 7
  • Gnu gcc compiler для codeblocks скачать для windows
  • Git credential manager for windows как убрать