Using GIT to clone from a windows machine to a linux webserver (in house)
Here is a walkthrough someone else did. It goes step by step showing how to do what you want.
Git: move existing repository from PC to server, clone from server
On the Linux server, in a new directory do:
git init --shared --bare
Then on your local machine:
git remote add origin server:path/to/repo
git push --all origin
After that, the server will have a full copy of the repository, and you will be able to push and pull to and from it. There's no need to check out another clone from the server when you've already got one locally.
What's the 'standard' directory location to use when cloning a Git repo onto a LINUX machine
What is the professionally expected location
If as you say you're deploying an app that's compiled from source, then there's no such location. In a professional environment your sources don't go on the servers.
From most professional to "it works" solutions:
Build system packages outside of your production environment. That means you have a repository of both previously deployed versions and have a package manifest including both build and runtime dependencies. That means you can rebuild your app the same way every time. For installation, install the built package. (this applies to deb, rpm, etc.)
Build tarballs with binaries in a predictable environment (developer's box). That means you run (for example, if you're using autotools)
./configure --prefix=/opt/your_app && make install DESTDIR=/tmp/somedirectory
- now you can pack the/tmp/somedirectory/opt/your_app
contents, copy it to a server and unpack it to/opt/your_app
.Clone it wherever (your home directory), then build, then install in the destination. Popular destinations are
/opt/app_name
and/usr/local
.
The solution depends on how professional the deployment really is, how many servers you've got, have you got test/production environment, etc.
How do I clone a Git repository into a specific folder?
Option A:
git clone git@github.com:whatever folder-name
Ergo, for right here
use:
git clone git@github.com:whatever .
Option B:
Move the .git
folder, too. Note that the .git
folder is hidden in most graphical file explorers, so be sure to show hidden files.
mv /where/it/is/right/now/* /where/I/want/it/
mv /where/it/is/right/now/.* /where/I/want/it/
The first line grabs all normal files, the second line grabs dot-files. It is also possibe to do it in one line by enabling dotglob (i.e. shopt -s dotglob
) but that is probably a bad solution if you are asking the question this answer answers.
Better yet:
Keep your working copy somewhere else, and create a symbolic link. Like this:
ln -s /where/it/is/right/now /the/path/I/want/to/use
For your case this would be something like:
ln -sfn /opt/projectA/prod/public /httpdocs/public
Which easily could be changed to test if you wanted it, i.e.:
ln -sfn /opt/projectA/test/public /httpdocs/public
without moving files around. Added -fn
in case someone is copying these lines (-f
is force, -n
avoid some often unwanted interactions with already and non-existing links).
If you just want it to work, use Option A, if someone else is going to look at what you have done, use Option C.
git clone on windows
If you have followed the tutorial Setting up a Msysgit Server with copSSH on Windows, I confirm your "Program Files (x86)
" can work.
See for instance SO answer "Git clone using ssh - can't find repository":
git clone "ssh://steve@test:4837/Program Files (x86)/ICW/home/steve/vc/git/depo/test.git"
/c/dev/es/app/
You will find other path examples in "How to stop git via ssh on windows from resolving the wrong path?".
Using Openssh rather than plink.exe is easier though: see "Setting up a Git server with Windows Server 2008".
As the OP JohnZ mentions in the comments:
Looks like this depends a little bit on the ssh server you use.
I installed CYGWIN, which has openSSH installed.
To clone it, I did this:
git clone "ssh://root@192.168.1.1/cygdrive/c/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/myrepofolder"
How to get Git to clone into current directory
The solution was using the dot
,
so:
rm -rf .* && git clone ssh://user@host.com/home/user/private/repos/project_hub.git .`
rm -rf .* &&
may be omitted if we are absolutely sure that the directory is empty.
Credits go to:
@James McLaughlin on comments
Hosting Git Repository in Windows
Here are some steps you can follow to get the git daemon running under Windows:
(Prerequisites: A default Cygwin installation and a git client that supports git daemon)
Step 1: Open a bash shell
Step 2: In the directory /cygdrive/c/cygwin64/usr/local/bin/, create a file named "gitd" with the following content:
#!/bin/bash
/usr/bin/git daemon --reuseaddr --base-path=/git --export-all --verbose --enable=receive-pack
Step 3: Run the following cygrunsrv command from an elevated prompt (i.e. as admin) to install the script as a service (Note: assumes Cygwin is installed at C:\cygwin64):
cygrunsrv --install gitd \
--path c:/cygwin64/bin/bash.exe \
--args c:/cygwin64/usr/local/bin/gitd \
--desc "Git Daemon" \
--neverexits \
--shutdown
Step 4: Run the following command to start the service:
cygrunsrv --start gitd
You are done. If you want to test it, here is a quick and dirty script that shows that you can push over the git protocol to your local machine:
#!/bin/bash
echo "Creating main git repo ..."
mkdir -p /git/testapp.git
cd /git/testapp.git
git init --bare
touch git-daemon-export-ok
echo "Creating local repo ..."
cd
mkdir testapp
cd testapp
git init
echo "Creating test file ..."
touch testfile
git add -A
git commit -m 'Test message'
echo "Pushing master to main repo ..."
git push git://localhost/testapp.git master
Related Topics
Read Lines Between Two Keywords
"Hello World" Function Without Using C Printf
Raising Hard Limit on Rlimit_Nofile System-Wide on Linux
How to Log from a Non-Root Debian Linux Daemon
Get X/Y Position of Caret (Input Text Cursor) Under Xorg
Why Does The Linker Modify a -Defsym "Absolute Address"
How to Speed Up a Video by Dropping Frames
How to Install Oracle 11G on Linux Without X
In Bash, How to Not Create The Redirect Output File Once The Command Fails
Individual Thread Priority Checking Using Command Line in Linux
Environment Variables in Docker When Exec Docker Run
Write and Read from Ttyusb0, Can't Get Response
Linux Command 'Ll' Is Not Working
Linux Kernel Aio, Open System Call