Need to change Git URL for repository

List your existing remotes in order to get the name of the remote you want to change (notice we forgot to include .git on the end of the repository directory)

 

cd project
git remote -v
origin ssh://USERNAME@SERVER/HOME/USERNAME/REPOSITORY (fetch) 
origin ssh://USERNAME@SERVER/HOME/USERNAME/REPOSITORY (push)

 

Change your remote’s URL  with the git remote set-url command.

git remote set-url origin ssh://USERNAME@SERVER/HOME/USERNAME/REPOSITORY.git

 

Verify that the remote URL has changed.

git remote -v
# Verify new remote URL
origin ssh://USERNAME@SERVER/HOME/USERNAME/REPOSITORY.git (fetch) 
origin ssh://USERNAME@SERVER/HOME/USERNAME/REPOSITORY.git (push)

 

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)
$

Git with Visual Studio Express 2013

EXIT Visual Studio!

ndavie@ARIEL-I7 MINGW64 /l/users/ndavie/Documents/Visual Studio 2013/Projects
$ git clone ssh://git@gitserver/home/git/6502Flags.git
Cloning into '6502Flags'...
git@gitserver's password:
remote: Counting objects: 18, done.
remote: Compressing objects: 100% (18/18), done.
Rremote: Total 18 (delta 1), reused 0 (delta 0)
Receiving objects: 100% (18/18), 14.20 KiB | 0 bytes/s, done.
Resolving deltas: 100% (1/1), done.

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

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

ndavie@ARIEL-I7 MINGW64 /l/users/ndavie/Documents/Visual Studio 2013/Projects/6502Flags (master)
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        modified:   6502Flags/6502Flags.csproj
        modified:   6502Flags/Form1.cs
        modified:   6502Flags/Properties/AssemblyInfo.cs

ndavie@ARIEL-I7 MINGW64 /l/users/ndavie/Documents/Visual Studio 2013/Projects/6502Flags (master)
$ git commit -m "updated version number"
[master 0ac0e95] updated version number
 3 files changed, 38 insertions(+), 3 deletions(-)

ndavie@ARIEL-I7 MINGW64 /l/users/ndavie/Documents/Visual Studio 2013/Projects/6502Flags (master)
$ git push origin master
git@gitserver's password:
Counting objects: 7, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (7/7), done.
Writing objects: 100% (7/7), 1.22 KiB | 0 bytes/s, done.
Total 7 (delta 5), reused 0 (delta 0)
To ssh://gitserver/home/git/6502Flags.git
   b681b92..0ac0e95  master -> master

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

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