Using SVN on Windows with Cygwin and TortoiseSVN - windows

I'm quite a beginner with version control so I might be doing something very wrong.
I want to be able to access a local repository both in cygwin and in TortoiseSVN (or other Windows app). The trouble is, in cygwin I have to use the
file:///cygdrive/c/... paths while TortoiseSVN needs
file:///c:/....
How can I make these two work together? Can I use some other path/protocol that both understand?
Thanks!

Easy way is to use the svnserve program that comes with Subversion. This should be in Cygwin. All you need to do is start up the svnserve and use svn:// as the protocol instead of file://.
First, you need to modify your repository. You'll have to edit two files: svnserve.conf and passed.
$ cd /cygdrive/c/.../repos_dir
$ cd conf
$ vi svnsever.conf # Change the "# password-db = passwd" line & remove the "#"
$ vi passwd # Setup the user and password entry
Next, you start the server:
$ cd .. # Back to the repository directory
$ svnserve -r $PWD -d
And, that's it.
Now, you can do your checkout this way:
$ svn co svn://localhost/dir/to/check/out
This will be the same URL in both cygwin and in Tortoise
WORD 'O WARNING
There is no guarantee that different subversion clients will produce working directories that will work with other subversion clients.
Fortunately, Tortoise and the standard Subversion command line client seem to be okay. I've been able for the last few years to switch between the Subversion command line client and ToroiseSVN. HOWEVER, you do have to make sure that they're both ether post version 1.7 clients or pre 1.7 clients. If your Cygwin client is version 1.6.7 and your Tortoise client is 1.7.5, you can't share the working directory. Use the svn version command to check your Cygwin client, and check the About Box on Tortoise.
Again, there's no guarantee that both clients can share the same working directory, so if there are problems, you are on your own.

There is a better way. Simply link the directory.
ln -s /cygdrive/c /C:
now it should work.
Credit goes to Mark Malaknov
You can read it here:
http://markmal.blogspot.com/2012/11/how-to-use-cygwin-svn-and-tortoisesvn.html

If you (re-)install TortoiseSVN and select the option to install the (Windows) command-line tools, but don't install the Cygwin/Linux version of these tools from the Cygwin installer (or remove them), then your Windows tools will still be available via Cygwin.
These should accept Windows paths as if you were invoking them from the Command Prompt (although you might have to put them in quotes to avoid the bash shell from interpreting them)

Related

Git print files in Windows Format

The most common use case I deal with git is to checkout file or remove or add file from Windows Command prompt.
I don't intend to use fancy gui tools. I like to work with keyboard and command prompt as much as possible.
So whenever I ask git status or any other report, git prints the file name like this
error: The following untracked working tree files would be overwritten by merge:
Tasks/Test/MyTest.js
The problem is, I can't just copy paste that text and use git checkout or git add anything. Since Windows can't understand / it expects you to give with \
Is there anyway git can print the info in Windows format or Windows can accept the *nix format [del Tasks/Test/MyTest.js]
I just tested Git using the Command Prompt and I had no trouble running git add on a file path which included forward slashes, so I don't see your problem as being reproducible.
Another option for you to consider is to use the Git Bash command line tool which ships with the Windows download of Git. The bash is a window, similar in appearance to the Command Prompt, but more powerful. On my Windows setup the Git Bash program is located here:
C:\Program Files\Git\git-bash.exe
The Git Bash tool does not make a distinction between / and \ in the path. Since either will work, you only need to copy the output you want, which is also easy and straightforward.
And good for you for sticking to command line Git. I believe you will become a stronger Git user by learning the nuts and bolts first on the command line.

Bazaar locks in Windows

I am new to Bazaar, but that's what is being use at my new job right now. I have installed the latest stable version 2.5.1 on my Windows 7 x64 machine and I can't seem to get it to work.
Every single operation I make, either with the command line tools or the GUI tools end up with the same result. An error window pops up to tell me the program could not acquire a lock.
Every time, the application I'm using will freeze for about 10 seconds, then this shows up and if I click Ignore, nothing happens. My changes are not saved and nothing is applied. If I choose to close the app, I lose all my changes. It even does that when I click the red X to close the application.
In the command line, I try to init a repository and I also get a lock error, but it's different this time. There's an error with a lock inside the repository I'm trying to create.
I just can't figure it out at all and I need help.
The version of Bazaar I'm using is 2.5.1 with the bundled Python v2.6.6 and Tortoise BZR.
I've installed bazaar in cygwin instead and have been using that for a couple of days now. But, to be able to use the GUI tools, I had to do a couple of tricks. I got them to work and here's what I did. It's a workaround if anybody else is stuck with the same issue. Basically here's what I did.
Through the Cygwin setup, install the following packages:
bzr
python3
python3-pyqt4
python-pyqt4 (I wasn't sure which one to install, so I installed both, but I think this one is not necessary.)
xinit
libqt4core (I think, but I'm not sure. Can't remember if I had to install it or if it was installed as a dependency with python3-pyqt4.)
Then download the individual Windows packages for the bazaar plugins you want to use. In my case I downloaded:
qbzr
bzrtools
bazaar explorer
I installed the plugins under c:\bazaar and the installers put them under C:\Bazaar\2.0\plugins.
In a Cygwin terminal, in my home dir, I created the directory ~/.bazaar/plugins/ and in that directory I made a sym link of every directory under C:\Bazaar\2.0\plugins.
After that, in the cygwin terminal, start up a new X-server using the startxwin command. Then export the DISPLAY variable so that your graphical tools know which X session to output to.
$ export DISPLAY=:0.0
Also, in case you get the annoying xterm when you start X, just create an empty file called .startxwinrc in your home directory.
Then, when you enter the commands bzr qlog, bzr explorer, bzr qbzr, the tools should open up through the X server and show up on your desktop. If any dependencies are missing, you will get an error message and you can install the missing package through Cygwin setup.
After that, if you want to use your favourite windows merge tool and editors with bazaar in Cygwin, they won't be able to interpret the Cygwin paths. So instead, I created a ~/bin/ folder and made a few scripts that call my favourite apps and that translate the file paths given as arguments using cygpath -w. Here's an example for p4merge:
#!/bin/bash
if [ "$#" = "2" ]; then
this=`cygpath -w $1`
other=`cygpath -w $2`
/cygdrive/c/Program\ Files/Perforce/p4merge.exe $this $other
elif [ "$#" = "4" ]; then
base=`cygpath -w $1`
this=`cygpath -w $2`
other=`cygpath -w $3`
result=`cygpath -w $4`
/cygdrive/c/Program\ Files/Perforce/p4merge.exe $base $this $other $result
else
echo "Invalid number of arguments."
echo "Usage: p4merge.sh <this> <other> or p4merge.sh <base> <this> <other> <result>"
exit 1
fi
I configured my bzr explorer to use that as a diff viewer and merge tool and it works perfectly.
Old question but I got the same error today. I solved it by simply deleting the content of the directory "C:\Users\{username}\AppData\Roaming\bazaar\2.0\lock"
Happened on a Win 7 x64 machine

Colored Output with Cygwin Commands on cmd

Operating system: Windows XP SP3 (Unfortunately)
I have downloaded and installed the latest version of Cygwin and Git. I also have configured my environment to include the "bin" folders for each in my system path and also set a user variable TERM=msys. I can now go into cmd and use the following command, for example:
git status
and get colored output, i.e. for status, changes to be committed are green, while untracked files and such are red. This was not the case without having set TERM=msys.
However, since I also added the Cygwin bin to my path, I can use
ls
to get a directory listing, but not with colored output. Am I correct in assuming that, since I'm only using the binaries through cmd, and not Cygwin itself, that getting colored output would have to be done differently from just configuring a BASH profile? Assuming this is possible; however it would seem to follow that if it can be done with Git, then it can also be done with the Cygwin binaries.
I'd be happy to elaborate or clarify any details. Thanks.
The basic colors should still work when you do ls --color. Since you can't use alias in cmd.exe, you can use the doskey windows utility.
doskey ls=ls --color
There are various ways you can make it so the command gets run automatically every time you start a cmd.exe shell. Here's one: http://www.tildemark.com/loading-doskey-automatically-with-cmd/

Git with SSH on Windows

I've went through the excellent guide provided by Tim Davis which is about configuring Git to work with SSH under Windows in order to produce a Git Server in order to have a main place for my DVCS.
I am in the process of creating a clone for my project. I’ve went through all the steps till this point, but I keep getting this from TortoiseGit:
git.exe clone -v “ssh://Administrator#127.0.0.1:22/SSH/Home/administrator/myapp.git” “E:\GitTest\myapp”
bash: Administrator#127.0.0.1: command not found
Initialized empty Git repository in E:/GitTest/myapp/.git/
fatal: The remote end hung up unexpectedly
Success
and nothing gets cloned.
BTW: The TortoisePLink comes up just before this message appears and asks me: “login as:” ( I thought that this info is given in the command, i.e: Administrator#blahblah.
My home variable is set to the correct place:
From a Git Bash shell:
echo $HOME
/c/SSH/home/Administrator
I’ve also tried using Putty’s plink instead of TortoisePLink (in both Git’s and TortoiseGit’s installation). This time the error was narrowed down to:
git.exe clone -v “ssh://Administrator#127.0.0.1:22/c:/SSH/Home/administrator/myapp.git” “E:\GitTest\myapp”
Initialized empty Git repository in E:/GitTest/myapp/.git/
fatal: The remote end hung up unexpectedly
I fought with this problem for a few hours before stumbling on the obvious answer. The problem I had was I was using different ssh implementations between when I generated my keys and when I used git.
I used ssh-keygen from the command prompt to generate my keys and but when I tried "git clone ssh://..." I got the same results as you, a prompt for the password and the message "fatal: The remote end hung up unexpectedly".
Determine which ssh windows is using by executing the Windows "where" command.
C:\where ssh
C:\Program Files (x86)\Git\bin\ssh.exe
The second line tells you which exact program will be executed.
Next you need to determine which ssh that git is using. Find this by:
C:\set GIT_SSH
GIT_SSH=C:\Program Files\TortoiseSVN\bin\TortoisePlink.exe
And now you see the problem.
To correct this simply execute:
C:\set GIT_SSH=C:\Program Files (x86)\Git\bin\ssh.exe
To check if changes are applied:
C:\set GIT_SSH
GIT_SSH=C:\Program Files (x86)\Git\bin\ssh.exe
Now git will be able to use the keys that you generated earlier.
This fix is so far only for the current window. To fix it completely you need to change your environment variable.
Open Windows explorer
Right-click Computer and select Properties
Click Advanced System Settings link on the left
Click the Environment Variables... button
In the system variables section select the GIT_SSH variable and press the Edit... button
Update the variable value.
Press OK to close all windows
Now any future command windows you open will have the correct settings.
Since this keeps coming up in search results for making git and github work with SSH on Windows (and because I didn't need anything from the guides above), I'm adding the following, simple solution.
(Microsoft says they are working on adding SSH to Visual Studio, and GitHub for Windows still doesn't support SSH...)
1. I installed "git for Windows" (which includes ssh and a bash shell)
https://git-scm.com/download/win
2. From the included bash shell (which, for me, was installed at: C:\Program Files\Git\git-bash.exe)
cd to the root level of where you want your repo saved (something like: C:\code\github\), and
Type:
eval $(ssh-agent -s) && ssh-add "C:\Users\YOURNAMEHERE\.ssh\github_rsa"
3. Type: (the SSH link from the repo)
git clone git#github.com:RepoName/Project.git
you are using a smart quote “ instead of " here:
git.exe clone -v “ssh://
^^^
Make sure you use the plain-old-double-quote.
I've found my ssh.exe in C:/Program Files/Git/usr/bin directory.
If Git for windows is installed, run Git Bash shell:
bash
You can run ssh from within Bash shell (Bash is aware of the path of ssh)
To know the exact path of ssh, run "where" command in Bash shell:
$ where ssh
you get:
c:\Program Files\Git\usr\bin\ssh.exe
I was trying to solve my issue with some of the answers above and for some reason it didn't work. I did switch to use the git extensions and this are the steps I did follow.
I went to Tools -> Settings -> SSH -> Other ssh client
Set this value to C:\Program Files\Git\usr\bin\ssh.exe
Apply
I guess that this steps are just the same explained above. The only difference is that I used the Git Extensions User Interface instead of the terminal. Hope this help.
When I typed where ssh it showed me multipe ssh.exe
user#pc MINGW64 /c/dev/
$ where ssh
C:\Users\user\AppData\Local\Programs\Git\usr\bin\ssh.exe
C:\Windows\System32\OpenSSH\ssh.exe
Deleting / moving these exe helped:
# copy from
# C:\Users\user\AppData\Local\Programs\Git\usr\bin
# to something like
# C:\Users\user\AppData\Local\Programs\Git\usr\bin\backup-ssh
ssh-agent.exe
ssh.exe
ssh-add.exe
This solved the issue for me.

Want to download a Git repository, what do I need (windows machine)?

I want to download this open source application, and they are using Git. What do I need to download the code base?
Update
How do I change the working directory when I am using Git Bash? (I want to download the repo at a certain directory, using pwd tells me I will be downloading the repo where I don't want it.
Download Git on Msys. Then:
git clone git://project.url.here
Install mysysgit. (Same as Greg Hewgill's answer.)
Install Tortoisegit. (Tortoisegit requires mysysgit or something similiar like Cygwin.)
After TortoiseGit is installed, right-click on a folder, select Git Clone..., then enter the Url of the repository, then click Ok.
This answer is not any better than just installing mysysgit, but you can avoid the dreaded command line. :)
I don't want to start a "What's the best unix command line under Windows" war, but have you thought of Cygwin? Git is in the Cygwin package repository.
And you get a lot of beneficial side-effects! (:-)
To change working directory in GitMSYS's Git Bash you can just use cd
cd /path/do/directory
Note that:
Directory separators use the forward-slash (/) instead of backslash.
Drives are specified with a lower case letter and no colon, e.g. "C:\stuff" should be represented with "/c/stuff".
Spaces can be escaped with a backslash (\)
Command line completion is your friend. Press TAB at anytime to expand stuff, including Git options, branches, tags, and directories.
Also, you can right click in Windows Explorer on a directory and "Git Bash here".

Resources