Learning how to use SVN/Git, couple questions

Red Squirrel

No Lifer
May 24, 2003
70,663
13,834
126
www.anyf.ca
I finally decided to start using SVN for one of my projects as we're two people working on it and it becomes a hassle having to manually put files in the right place and stuff, so figured it would make things easier.

I have a few questions.

1: When I do any operation in command line it keeps asking to store password in clear text, I don't want to store password, how do I make it so it stops prompting me for this?

Code:
[root@appdev src]# svn commit -m "test commit"
Authentication realm: <https://echoriath.loc:443> Subversion repo: test
Password for 'testuser': 

-----------------------------------------------------------------------
ATTENTION!  Your password for authentication realm:

   <https://echoriath.loc:443> Subversion repo: test

can only be stored to disk unencrypted!  You are advised to configure
your system so that Subversion can store passwords encrypted, if
possible.  See the documentation for details.

You can avoid future appearances of this warning by setting the value
of the 'store-plaintext-passwords' option to either 'yes' or 'no' in
'/root/.subversion/servers'.
-----------------------------------------------------------------------
Store password unencrypted (yes/no)? no
Sending        stuff.cpp
Transmitting file data .
Committed revision 2.
[root@appdev src]#



2:

When browsing via browser in apache, is there a way to browse previous revisions? If I go to the URL it shows the latest, but is there some kind of url trick to go to older ones? Is there a way to get a date on when that revision was made, or other such details?

3:

I was reading that you need to use SVN specific commands if you are creating or renaming files/directories. Is this really the case? Seems like quite a hassle. I tend to just work directly off my NFS share and use a text editor and create/delete stuff at will which is a large part of the development process. Do I really need to jump on the dev server and use the SVN commands every time I want to do something like that?
 
Last edited:

Ken g6

Programming Moderator, Elite Member
Moderator
Dec 11, 1999
16,703
4,661
75
First, I just want to say, use Git! It's much better!

When browsing via browser in apache, is there a way to browse previous revisions?
I don't know. It takes more than Subversion to show Subversion versions in Apache. What other software are you using?

I was reading that you need to use SVN specific commands if you are creating or renaming files/directories.
When creating files/directories, you can wait before you add them. You need SVN specific commands to rename or delete them. If you delete files without SVN it's a real pain fixing that. Git is a little more forgiving of renaming and deletion, but it's better to use the git-specific commands if you can.

Edit: I just read the rest of this:

I tend to just work directly off my NFS share and use a text editor and create/delete stuff at will which is a large part of the development process. Do I really need to jump on the dev server and use the SVN commands every time I want to do something like that?

In theory, you should have your own local server on your local machine that you develop on. When stuff's working, then you should push to the dev server.

Of course, for my work, I do work on the dev server and send stuff over FTP. So do as I say, not as I do, OK? ;)
 
Last edited:

Red Squirrel

No Lifer
May 24, 2003
70,663
13,834
126
www.anyf.ca
I was reading that Git is more of a pain in the ass and you're spending more time having to administrate it than actually coding, so I had opted to just go SVN. It's already mostly setup now. I figured out how to browse the different revisions, just need to add ?p=1 at the end of the url where 1 is revision. So that's nice, though it would be nice if it provided some form of date/time stamping on files in the display directory. Is this something git would do?

It is kind of annoying that deleting/adding files is going to require using the special commands though. Guess it's just something we'll have to get used to. I guess in a way it's good as it makes it easy to exclude files as I just need to not add them. So if I make myself a little readme note or something and don't really want to publish it I don't have to. I have lot of misc helper files/scripts as well that I wont really want to publish as they are specific to my own dev environment so I just need to not add those either.
 

Ken g6

Programming Moderator, Elite Member
Moderator
Dec 11, 1999
16,703
4,661
75
I was reading that Git is more of a pain in the ass and you're spending more time having to administrate it than actually coding
That's funny, that's how I feel about SVN. D:

Git requires a different mindset. For SVN you have lots of clients working with one SVN server. For Git, all the clients are practically Git servers, except the main Git server is your server's server. This means you can do anything you want on your Git client. Make all the branches you want - you don't have to pass them to the main server. Try a crazy idea and it doesn't work? Save it in a local branch. You never know when you might want to come back to it.

I haven't figured out how you handle conflicts between your local machine and a SVN server. Copy your changes, overwrite them, then try to merge? :confused: With Git, it auto-merges when you pull. Easy-peasy - or as easy as it can get when two people have been editing the same code. Plus, every revision is a branch, or can be, so there's no worries unless you do something crazy like rebase.
 

Red Squirrel

No Lifer
May 24, 2003
70,663
13,834
126
www.anyf.ca
Well I think I'm already starting to hate SVN.

It locked up in the middle of my first commit while uploading files, it just stopped outputting more dots. So I had to kill -9 the process. Now I can't do anything because I just get a bunch of errors.

Code:
[root@appdev src]# svn cleanup
svn: In directory 'scripts/Items/Facial'
svn: Error processing command 'committed' in 'scripts/Items/Facial'
svn: Working copy 'scripts/Items' locked
svn: run 'svn cleanup' to remove locks (type 'svn help cleanup' for details)
[root@appdev src]#

I'm TRYING to run svn cleanup, but it spits out the error and then tells me to run it.

Is this kind of crap common with SVN?
 

Merad

Platinum Member
May 31, 2010
2,586
19
81
I too recommend git. It can be intimidating, and some of its commands are very unintuitive, but it's so popular now than basically any problem you run into can be solved with a few minutes googling.
 

postmortemIA

Diamond Member
Jul 11, 2006
7,721
40
91
svn cleanup needs to be done on the root of the checkout
you got any UI svn clients? Looks like you're not running the Windows, in which case I'd recommend TortoiseSVN.
 

purbeast0

No Lifer
Sep 13, 2001
53,658
6,533
126
if you are just starting out, i'd ditch SVN and just start with git. it's more complicated but it's more powerful and easier once you get the hang of it.

from what i've seen from your post history, i believe you are a linux guy, so you shouldn't have problems learning how to use it and reading docs.
 

Red Squirrel

No Lifer
May 24, 2003
70,663
13,834
126
www.anyf.ca
I was at the root when trying to do cleanup. There does not seem to be very many good intuitive GUI clients in Linux, but I'm running this directly on the dev server (not SVN server, that's another VM) and not my workstation so command line is fine. But yeah think I'll just ditch SVN and go with git after all. Any good tutorial recommendations for server and client side? And yeah I'm running a full Linux environment. What I'll probably end up doing is scripting it so I just have to do ./checkout to pull the latest version and ./commit to commit latest version from within the dev environment. For conflicts I'll probably want to use a GUI compare tool to merge so I'll usually just make a backup of whatever files conflict then apply the new ones and merge with backup.
 

Red Squirrel

No Lifer
May 24, 2003
70,663
13,834
126
www.anyf.ca
Been reading on and off on git today, while lot of it seems complex, some of it is actually simpler, like the fact that you can use SSH as a transfer protocol. That will simplify my security and authentication setup, as I simply give my friend a ssh account to the git server and he can manage his account, change password etc... and it's encrypted and secure to boot, and I can setup fail2ban for brute force attack protection, which allows me to simply open up the port directly and not worry about anything. If I want to add more users I just create a ssh account. Probably can use key pairs too to make it easier to automate as I'll probably want to automate check out / commit through a simple script on my dev server.

Guessing lot of the advanced git stuff I don't necessarily have to worry about at first anyway, can always go back if I find I need those features. Like I don't see myself needing to do branching or anything, it will just be one continuous branch, but the idea is that we don't have to keep sending each other files by email and having to manually place them where they go, git will take care of that for us.

I ALMOST had SVN working and liked it, but after that first lock up issue during a commit, did not want to chance that happening when we're actually in prod. It looks like it left lock files in every single folder and it would have taken a very long time to go around cleaning those up to try to fix the local repo, so screw that.
 

Red Squirrel

No Lifer
May 24, 2003
70,663
13,834
126
www.anyf.ca
Ok this is getting confusing. I'm trying to setup the central repository but I just can't get it to work. So I have to run this command:

git clone --bare project project.git

What does project refer to? Is that the folder with all my files? And what is the .git file? Do I run this on the server or on the machine that has the existing files? So I copy that to the server, but now that has all the git related files in it, shouldn't it have my project's files, and have it's own .git folder? I'm so confused. when I try to publish new changes to the server it just says everything is up to date but none of my files are on the server. I added a folder and did a commit locally but it wont copy those files to the server, keeps saying it's up to date.

I tried to skip that part and just do git init on the empty project folder on the server, but if I try to commit to that I get this error: So clearly there's something to that clone command, I just don't get what all the parameters mean or where exactly the folder goes.

Code:
[root@appdev src]# git push main master
Counting objects: 5476, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (5409/5409), done.
Writing objects: 100% (5476/5476), 20.66 MiB | 2.65 MiB/s, done.
Total 5476 (delta 2285), reused 0 (delta 0)
remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, updating the current branch in a non-bare repository
remote: error: is denied, because it will make the index and work tree inconsistent
remote: error: with what you pushed, and will require 'git reset --hard' to match
remote: error: the work tree to HEAD.
remote: error: 
remote: error: You can set 'receive.denyCurrentBranch' configuration variable to
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into
remote: error: its current branch; however, this is not recommended unless you
remote: error: arranged to update its work tree to match what you pushed in some
remote: error: other way.
remote: error: 
remote: error: To squelch this message and still keep the default behaviour, set
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
To gituser@echoriath.loc:/localdata/gitrepos/aov/
 ! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'gituser@echoriath.loc:/localdata/gitrepos/aov/'

Can someone explain in more details how to setup the empty server repo so I can do an initial push to it? The tutorials are just too vague. As an example my folder on the server is /localdata/gitrepos/aov. I want my actual files to be in the aov folder and then the .git will be in there too. The clone command seems to insist I actually call it aov.git and then it actually puts what normally goes in .git directly in that folder. That's the part I'm confused about.
 

Red Squirrel

No Lifer
May 24, 2003
70,663
13,834
126
www.anyf.ca
Now I'm even more confused. I decided to take a different approach, decided to do git init on the git server, and then on the dev server I just start a new folder and do a git clone and pull the blank directory from the server so I can then add my files commit and publish to git server, but it locks up at Resolving deltas: 100% (2285/2285), done and I googled this and it's a known bug. I ctrl+c out of it.

Now I have a folder called web and a folder called aov, and the aov folder has the files I was trying to commit earlier. Where did it even get those files? They were not even on the git server because my past attempts were failing, and I blanked that directory to begin with. And why is it making those folders, if anything I want the files in the root folder that I'm working from, this is critical for the rest of the work flow because I have scripts that depend on the files being in that folder. But I'm more confused as to where it's even getting those files from because I blanked out the remote folder into a new repo by using git init after deleting the .git folder.
 
Last edited:

Merad

Platinum Member
May 31, 2010
2,586
19
81
Honestly just use Github or Bitbucket unless you have a good reason not to.
 

Red Squirrel

No Lifer
May 24, 2003
70,663
13,834
126
www.anyf.ca
Was looking at that actually, but I want to get a basic setup going first, but may look at it later as it looks pretty good.

I just discovered something weird. Since when does rm -rf not actually delete everything? I just noticed that when I do rm -rf * inside the folder the .git and .svn (from previous attempts) folders are still there. How can this be? I have to backtrack and delete the entire folder and recreate it. Maybe that's the source of some of my issues, some residual stuff was staying behind.

I think I almost got it working, so on the git server I did the following:

1: Deleted the entire repo folder for my project to make sure no residual files are in there, as I discovered rm -rf * was not actually deleting everything. Chowned it to gituser which is a user I created and will use when commiting remotely.

2: git init

3: vim afile.txt - just added garbage in there

4: git commit


On a test git client I did the following:

1: cleared the project folder completely and recreated it

2: git clone gituser@gitserver:/path/to/project/ .

This worked, it took down everything including the file I created.

3: modified the file

4: git commit

And this is where I run into an issue:

5:

Code:
[root@appdev src]# git checkout
Your branch is ahead of 'origin/master' by 1 commit.
[root@appdev src]# git push origin master
Counting objects: 5, done.
Writing objects: 100% (3/3), 264 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, updating the current branch in a non-bare repository
remote: error: is denied, because it will make the index and work tree inconsistent
remote: error: with what you pushed, and will require 'git reset --hard' to match
remote: error: the work tree to HEAD.
remote: error: 
remote: error: You can set 'receive.denyCurrentBranch' configuration variable to
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into
remote: error: its current branch; however, this is not recommended unless you
remote: error: arranged to update its work tree to match what you pushed in some
remote: error: other way.
remote: error: 
remote: error: To squelch this message and still keep the default behaviour, set
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
To gituser@echoriath.loc:/localdata/gitrepos/aov/
 ! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'gituser@echoriath.loc:/localdata/gitrepos/aov/'

So close. What am I doing wrong here? There's a part in the doc about staging and all that, but I'm just confused by what all that means, so I'm guessing I missed a step somewhere.
 
Last edited:

Red Squirrel

No Lifer
May 24, 2003
70,663
13,834
126
www.anyf.ca
Yeah knew it was hidden, but figured rm -rf should still delete them. But now that I got that figured out I'm very close, just need to figure out why it wont let me commit back to the git server, there's probably a step I'm missing. I'm going through the tutorials again.
 

purbeast0

No Lifer
Sep 13, 2001
53,658
6,533
126
i ALWAYS do a git pull --rebase after a commit and before i push to origin. that way i'm guaranteed that my stuff will have what is in origin + my stuff on top of it.

(this is assuming you are just in a working branch and NOT doing a merge)
 

Crusty

Lifer
Sep 30, 2001
12,684
2
81
When you do rm -rf * you are using a shell glob to translate the command into something like 'rm -rf file1 file2 file3 dir1 dir2', this won't include hidden directories or files. If your goal is to remove ALL of the contents of the current directory you should cd to its parents directory then do a 'rm -rf directory_to_remove' and just delete the entire thing. If you need to use the directory again you can just create it again.
 

Red Squirrel

No Lifer
May 24, 2003
70,663
13,834
126
www.anyf.ca
When you do rm -rf * you are using a shell glob to translate the command into something like 'rm -rf file1 file2 file3 dir1 dir2', this won't include hidden directories or files. If your goal is to remove ALL of the contents of the current directory you should cd to its parents directory then do a 'rm -rf directory_to_remove' and just delete the entire thing. If you need to use the directory again you can just create it again.

Yeah did not know that till now. Wanted to save myself from outright deleting it because then I have to redo the permissions, but now I know. Had to set permissions on .git folder anyway when I'd create a new one, so comes up to same thing.

I think I nearly got it working, can you tell me if my work flow is in the right track?


On git server I setup bare repository:

Code:
[root@echoriath aov]# git --init --bare
Unknown option: --init
usage: git [--version] [--exec-path[=GIT_EXEC_PATH]] [--html-path]
           [-p|--paginate|--no-pager] [--no-replace-objects]
           [--bare] [--git-dir=GIT_DIR] [--work-tree=GIT_WORK_TREE]
           [--help] COMMAND [ARGS]
[root@echoriath aov]# 
[root@echoriath aov]# 
[root@echoriath aov]# git init --bare
Initialized empty Git repository in /localdata/gitrepos/aov/
[root@echoriath aov]# 
[root@echoriath aov]# 
[root@echoriath aov]# chown -R gituser:gituser .
[root@echoriath aov]# dir -a
total 40
4 drwxr-xr-x 7 gituser gituser 4096 Jul 26 19:19 .
4 drwxr-xr-x 3 gituser gituser 4096 Jul 26 19:19 ..
4 drwxr-xr-x 2 gituser gituser 4096 Jul 26 19:19 branches
4 -rw-r--r-- 1 gituser gituser   66 Jul 26 19:19 config
4 -rw-r--r-- 1 gituser gituser   73 Jul 26 19:19 description
4 -rw-r--r-- 1 gituser gituser   23 Jul 26 19:19 HEAD
4 drwxr-xr-x 2 gituser gituser 4096 Jul 26 19:19 hooks
4 drwxr-xr-x 2 gituser gituser 4096 Jul 26 19:19 info
4 drwxr-xr-x 4 gituser gituser 4096 Jul 26 19:19 objects
4 drwxr-xr-x 4 gituser gituser 4096 Jul 26 19:19 refs
[root@echoriath aov]#


I have two folders, one is just a test and the other will be where I actually work from, they're on the same server (don't think this matters does it? It's just for testing, only actually going to be working from one)


On first folder:

Code:
[root@appdev src]# git clone gituser@echoriath.loc:/localdata/gitrepos/aov .
Initialized empty Git repository in /network/appdev/dev/svntest/src/.git/
warning: You appear to have cloned an empty repository.
[root@appdev src]# 
[root@appdev src]# 
[root@appdev src]# 
[root@appdev src]# dir
total 0
[root@appdev src]# dir -a
total 12
4 drwxr-xr-x 3 appdev appdev 4096 Jul 26 19:30 .
4 drwxr-xr-x 3 appdev appdev 4096 Jul 26 19:28 ..
4 drwxr-xr-x 7 appdev appdev 4096 Jul 26 19:30 .git
[root@appdev src]# 
[root@appdev src]# 
[root@appdev src]# 
[root@appdev src]# vim file.txt  
[root@appdev src]# 
[root@appdev src]# git add file.txt
[root@appdev src]# 
[root@appdev src]# git commit -a
[master (root-commit) 827acfe] first commit
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 file.txt
[root@appdev src]# 
[root@appdev src]# 
[root@appdev src]# git push origin master
Counting objects: 3, done.
Writing objects: 100% (3/3), 212 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To gituser@echoriath.loc:/localdata/gitrepos/aov
 * [new branch]      master -> master
[root@appdev src]#

On other (new) folder:


Code:
[root@appdev src]# git clone gituser@echoriath.loc:/localdata/gitrepos/aov .
Initialized empty Git repository in /network/appdev/dev/aov/src/.git/
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (3/3), done.
[root@appdev src]# dir
total 4
4 -rw-r--r-- 1 appdev appdev 7 Jul 26 19:32 file.txt
[root@appdev src]# cat file.txt 
a file
[root@appdev src]# 
[root@appdev src]# vim file.txt 
[root@appdev src]# 
[root@appdev src]# git commit -a
[master dd33059] first change
 1 files changed, 2 insertions(+), 0 deletions(-)
[root@appdev src]# 
[root@appdev src]# 
[root@appdev src]# git push
Counting objects: 5, done.
Writing objects: 100% (3/3), 260 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To gituser@echoriath.loc:/localdata/gitrepos/aov
   827acfe..dd33059  master -> master
[root@appdev src]#



Back to 1st folder, to fetch new change:


Code:
[root@appdev src]# git pull
remote: Counting objects: 5, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From echoriath.loc:/localdata/gitrepos/aov
   827acfe..dd33059  master     -> origin/master
Updating 827acfe..dd33059
Fast-forward
 file.txt |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
[root@appdev src]# 
[root@appdev src]# 
[root@appdev src]# cat file.txt 
a file

made a change
[root@appdev src]#



So this seems to be working, did more testing than this and seems good so far but I'll have to add my entire project in and make sure things still work in that sense. The dev server repo folder is also where the program is actually ran from.

If I get a conflict where file was modified and I try to pull a modified version that would overwrite my changes I get an error indicating which file conflicts, so I just rename my file to something else, go ahead with the pull, then I can run a merge program to apply my changes and delete the backup I created. There's probably advance features to take care of this for me but I'm thinking this will be the simplest for now.

So basically before I begin any development I should do git pull to pull the latest version in case someone else worked on it. Then I can proceed to work, and when I'm done I do git commit -a and git push to push my changes to the repo. Idealy we communicate and try not to work on same files at same time so I don't think merging will be something we'll have to do very often.

Am I on the right path now? What about Windows Git clients, my friend is on Windows, will he be able to still connect through SSH and key pair auth like I'm doing? Since this will be opened up to the outside I don't really want to have any other ports opened.

I just realized I'm going to want to change that server to another port than 22 as I already have a ssh server listening on that outside port, hopefully that wont be an issue.
 
Last edited:

purbeast0

No Lifer
Sep 13, 2001
53,658
6,533
126
if you are trying to do a git pull and it would overwrite your current changes, then you need to stash your changes or commit them, then rebase your current branch with origin. i think in general if you have changes locally you can't just pull without doing something about your modified status.

as far as windows git clients, the best is tortoise git. but i'd really recommend learning the command line. i was very strong on tortoisegit and know how to use it well, however i've ran into issues a few months ago merging stuff so i've been using command line instead for the most part, and i've really learned A LOT about what is going on with git under the hood because of it.

but if you MUST use a gui, tortoisegit is what i'd recommend. it's good for basic stuff (as well as some advanced stuff, just be careful).
 

Red Squirrel

No Lifer
May 24, 2003
70,663
13,834
126
www.anyf.ca
if you are trying to do a git pull and it would overwrite your current changes, then you need to stash your changes or commit them, then rebase your current branch with origin. i think in general if you have changes locally you can't just pull without doing something about your modified status.

as far as windows git clients, the best is tortoise git. but i'd really recommend learning the command line. i was very strong on tortoisegit and know how to use it well, however i've ran into issues a few months ago merging stuff so i've been using command line instead for the most part, and i've really learned A LOT about what is going on with git under the hood because of it.

but if you MUST use a gui, tortoisegit is what i'd recommend. it's good for basic stuff (as well as some advanced stuff, just be careful).

Is there a good command line git for windows that will also allow him to generate ssh keypair? This is for my friend as he develops on Windows. I'm on Linux so I'll be using command line directly from the dev server itself which is where I handle all my code.
 
Last edited: