Putting Existing Visual Studio project on remote server using Git

On Linux server:

mkdir my_project.git
cd my_project.git
git --bare init

On Windows client:

If your EXISTING project is called ‘my_project’ rename the directory to ‘my_project.temp’

Get appropriate .gitignore from here:  https://github.com/github/gitignore

mv my_project my_project.temp
git clone ssh://youruser@yourserver.com/home/youruser/my_project.git
cd my_project
git init
cp ../my_project.temp
cp ../../.gitignore .
git add *
git add .gitignore
git commit -m "Initial commit" 
git push origin master

CONFIRM that my_project is complete by getting getting the project on a different machine/folder and compiling it before removing the my_project.temp folder

REAL LIFE OUTPUT ON WINDOWS SIDE

ndavie@ARIEL-I7 MINGW64 /l/users/ndavie/Documents/Visual Studio 2013/Projects
$ mv WinLengthConsole WinLengthConsole.temp

ndavie@ARIEL-I7 MINGW64 /l/users/ndavie/Documents/Visual Studio 2013/Projects
$ git clone ssh://git@gitserver/home/git/WinLengthConsole.git
Cloning into 'WinLengthConsole'...
git@gitserver's password:
warning: You appear to have cloned an empty repository.

ndavie@ARIEL-I7 MINGW64 /l/users/ndavie/Documents/Visual Studio 2013/Projects
$ cd WinLengthConsole

ndavie@ARIEL-I7 MINGW64 /l/users/ndavie/Documents/Visual Studio 2013/Projects/WinLengthConsole (master)
$ cp ../WinLengthConsole.temp/* . -r

ndavie@ARIEL-I7 MINGW64 /l/users/ndavie/Documents/Visual Studio 2013/Projects/WinLengthConsole (master)
$ cp ../../.gitignore .

ndavie@ARIEL-I7 MINGW64 /l/users/ndavie/Documents/Visual Studio 2013/Projects/WinLengthConsole (master)
$ git add *
The following paths are ignored by one of your .gitignore files:
WinLengthConsole.v12.suo
Use -f if you really want to add them.

ndavie@ARIEL-I7 MINGW64 /l/users/ndavie/Documents/Visual Studio 2013/Projects/WinLengthConsole (master)
$ git add .gitignore

ndavie@ARIEL-I7 MINGW64 /l/users/ndavie/Documents/Visual Studio 2013/Projects/WinLengthConsole (master)
$ git status
On branch master

Initial commit

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)

        new file:   .gitignore
        new file:   WinLengthConsole.sln
        new file:   WinLengthConsole/App.config
        new file:   WinLengthConsole/Program.cs
        new file:   WinLengthConsole/Properties/AssemblyInfo.cs
        new file:   WinLengthConsole/WinLengthConsole.csproj


ndavie@ARIEL-I7 MINGW64 /l/users/ndavie/Documents/Visual Studio 2013/Projects/WinLengthConsole (master)
$ git commit -m "Initial Commit"
[master (root-commit) 03e3cc4] Initial Commit
 6 files changed, 722 insertions(+)
 create mode 100644 .gitignore
 create mode 100644 WinLengthConsole.sln
 create mode 100644 WinLengthConsole/App.config
 create mode 100644 WinLengthConsole/Program.cs
 create mode 100644 WinLengthConsole/Properties/AssemblyInfo.cs
 create mode 100644 WinLengthConsole/WinLengthConsole.csproj

ndavie@ARIEL-I7 MINGW64 /l/users/ndavie/Documents/Visual Studio 2013/Projects/WinLengthConsole (master)
$ git push origin master
git@gitserver's password:
Counting objects: 10, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (9/9), done.
Writing objects: 100% (10/10), 6.62 KiB | 0 bytes/s, done.
Total 10 (delta 0), reused 0 (delta 0)
To ssh://gitserver/home/git/WinLengthConsole.git
 * [new branch]      master -> master

ndavie@ARIEL-I7 MINGW64 /l/users/ndavie/Documents/Visual Studio 2013/Projects/WinLengthConsole (master)
$
Advertisements

Setting up a Git server (linux) and Git client (Windows 7)

On server (linux as gitserver):

On client (Windows 7):

Download windows installer from https://git-scm.com/download/win

Use these settings:

  • check Additional Icons and on the desktop, Use true type font
  • Start Menu Folder: Git
  • Use Git from Git Bash only
  • Use OpenSSH
  • Checkout Windows-style
  • Use MiniTTY
  • Enable file system caching and enable git credential Manager

Start Git Bash

cd ~/Documents
md GitServer
sudo apt-get install git-core
sudo useradd git
passwd git
ssh-keygen -t rsa

login in as git on linux server

mkdir .ssh && chmod 700 .ssh
touch .ssh/authorized_keys && chmod 600 .ssh/authorized_keys

copy/paste key generated key into authorized_keys

md project-1.git cd project-1.git git init --bare
mkdir project-1
cd project-1
git init
git config --global user.name "YOUR NAME"
git config --global user.email "YOUR EMAIL ADDRESS"

 

<<Add Some files>>

 

git add *
git commit -m "test" -a
git remote add origin ssh://git@gitserver/home/git/project-1.git
git push origin master

check using a different directory

md projects
cd projects
git clone ssh://git@gitserver/home/git/project-1.git
notepad "file" <- edit the file
git add *
git status
git commit -m "TEST2" -a
git push

Documentation on git:  https://git-scm.com/doc

Viewing the Commit History: git log

Viewing differences in last push (all files):  git diff HEAD HEAD^

Viewing differences from 2 pushes ago: git diff HEAD HEAD^2