简体   繁体   English

家庭作业的版本控制

[英]Version Control for Homework Assignments

School is back in session and I've found myself at a loss. 学校回来了,我发现自己不知所措。 At the end of last semester, we had a group project utilizing subversion (group of 4 people) to make commits and get it complete. 在上学期结束时,我们有一个小组项目利用subversion(4人组)进行提交并完成提交。 I also noticed how easy it was to have access to a central point for my homework. 我还注意到访问作业的中心点是多么容易。 I want to utilize SVN or Git (recently introduced to git) and I have a problem. 我想利用SVN或Git(最近引入git),我遇到了问题。

What is the best way to organize SVN for multiple homework assignments for multiple computer classes. 为多个计算机类组织多个家庭作业的SVN的最佳方法是什么。

I've got 2 programming classes that I definitely want to track. 我有2个编程类,我绝对想跟踪。 With at minimum of 1 assignment a week that's 32 assignments to manage over 2 classes. 每周至少进行1次任务,分配32个任务来管理2个以上的课程。 Should I keep them all in one repository and just label 1 Java and 1 C++? 我应该将它们全部保存在一个存储库中,只标记1个Java和1个C ++吗?

Thanks in advance. 提前致谢。

Edit: I should mention I have yearly hosting that allows both git and subversion through WebDAV. 编辑:我应该提到我有年度托管,允许通过WebDAV进行git和subversion。 That's how I accessed the svn repo for my project last year. 这就是我去年为我的项目访问svn repo的方式。 I have the ability to lock my homework up away from public view through this tool, for those not familiar with that setup. 对于那些不熟悉该设置的人,我有能力通过此工具锁定我的作业远离公共视图。

If you move between lots of computers you might wanna carry the assignments in a USB stick. 如果您在许多计算机之间移动,您可能希望在USB记忆棒中进行分配。 Assuming you're using git, there shouldn't be any problems. 假设你正在使用git,应该没有任何问题。

I usually have a folder for each class and under it a folder for each assignment, 我通常为每个类都有一个文件夹,每个文件夹下有一个文件夹,

cpsc511/
   a1/
   a2/
   a3/
cpsc423/
   a1/
   a2/
   a3/

Each assignment would have its own repository. 每个任务都有自己的存储库。 I don't see a reason to use the same repo for all assignments since most of the time they won't be related by anything at all. 我没有理由为所有作业使用相同的回购,因为大部分时间他们根本不会有任何关联。

Speaking for SVN - 为SVN发言 -
One repository with multiple projects is normal. 一个包含多个项目的存储库是正常的

You can easily setup a standalone SVN server (without needing a web server) on a PC 您可以在PC上轻松设置独立的SVN服务器(无需Web服务器)

You might also look at using svn with a file based repository on a USB key for simplicity between home and school. 您还可以在USB密钥上使用带有基于文件的存储库的svn,以简化家庭和学校之间的操作。 This is limited to only one user accessing the files but means you need nothing more than the SVN client (or TortoiseSVN) 这仅限于一个用户访问文件,但意味着您只需要SVN客户端(或TortoiseSVN)

ps. PS。 Learning to use SCC is one of the most important things they don't teach you at school. 学习使用SCC是他们在学校没有教你的最重要的事情之一。

In the spirit of learning, and sharing I'm posting two really great resources for both subversion and git. 本着学习和分享的精神,我为subversion和git发布了两个非常好的资源。 I think it'd up to anyone's very own situation to choose which is best for their needs. 我认为选择最符合他们需求的是由任何人自己的情况决定的。

Subversion Book - Version Control With Subversion Official Book Subversion Book - 版本控制与Subversion官方书籍

Git - Pro Git (Book) Great guide to using git Git - Pro Git(书)使用git的好指南

Git Hub - Learn Github (learn.github.com Just found this today. Git Hub - 学习Github(learn.github.com今天刚刚发现。

So far I've tried subversion and git, and found git with the setup hasen j described works best. 到目前为止,我已经尝试过subversion和git,并且发现使用hasen j设置的git效果最好。 I'll try to follow up again with this thread. 我会尝试再次跟进这个帖子。 Thanks again to all of your advice 再次感谢您的所有建议

You could consider using bitbucket.org , which offers Mercurial hosting with one private repository for free. 您可以考虑使用bitbucket.org ,它可以免费为Mercurial托管提供一个私有存储库。 It is a relatively easy source control system to learn, and there are plenty of tutorials and examples. 这是一个相对容易学习的源代码控制系统,有很多教程和示例。 You can also share this repo with your team mates during group projects. 您还可以在团队项目期间与团队成员共享此回购。 There are numerous services like this for git as well. git也有很多这样的服务。

I don't think there is a good reason to split your repository by technology (eg, Java/C++), but if you just have a directory layout like /assignments/course/assignment_x, you should be fine. 我不认为有充分的理由按技术(例如,Java / C ++)拆分您的存储库,但如果您只有像/ assignments / course / assignment_x这样的目录布局,那么您应该没问题。 There is probably some code that you can share across coursework, but I suppose that depends on the prof..... 可能有一些代码可以在课程中分享,但我想这取决于教授......

Another thing to keep in mind when you save your semesters work in the cloud is accessibility. 当您在云中保存学期工作时要记住的另一件事是可访问性。 I decided to backup every line of code I've written for my undergrad using the following script. 我决定使用以下脚本备份我为本科生编写的每一行代码。

#!/usr/bin/env python

import os
import smtplib
import sys

mail_server = '###'
from_email = '###'
sender = '###'
to_email = '###'
mailbox_name = '###'
mailbox_password = '###'

server = smtplib.SMTP(mail_server)
server.login(mailbox_name, mailbox_password)

repository, revision = sys.argv[1:]

# get info about the commit
cmd = "svnlook info %(repository)s" % locals()
info = os.popen(cmd).read()
info = info.split("\n")
author = info[0]
time = info[1]

# combines all lines of multi line comment into a single line
comment = info[3:len(info)]
temp = ""
for c in comment:
    temp += c + " "
comment = temp

# find out what changes are made
cmd = "svnlook changed %(repository)s" % locals()
changes = os.popen(cmd).read()

# include the diff between new and prior revision
cmd = "svnlook diff %(repository)s -r %(revision)s" % locals() 
diff = os.popen(cmd).read() 

msg = (
"To: %(to_email)s\r\n"
"From: %(sender)s %(from_email)s\r\n"
"Subject: Revision %(revision)s committed\r\n"
"Content-type: text/plain\r\n"
"\r\n"
"Revision: %(revision)s\r\n"
"Comment: %(comment)s\r\n"
"\r\n"
"Author: %(author)s\n"
"Time: %(time)s\r\n"
"\r\n"
"Files affected:\r\n"
"%(changes)s\r\n"
"Changes Made:\r\n"
"%(diff)s\r\n"
)

msg = msg % locals()

server.sendmail(from_email, to_email, msg)
server.quit()
  • Place this in 'svn-repo/hooks/' (save it as post-commit) 将其放在'svn-repo / hooks /'中(保存为提交后)
  • make it executable - 'chmod +x post-commit' 让它可执行 - 'chmod + x post-commit'

I it to your personal gmail address for two reasons: 1. I can simply search my inbox years from now using the simple gmail interface 2. You can wake up the next day after a long night of coding and review everything you commmitted as a sanity check - Many software companies follow this practice. 我将它发送到您的个人Gmail地址有两个原因:1。我可以使用简单的gmail界面从现在开始搜索我的收件箱2.您可以在经过漫长的编码之后第二天醒来并查看您提交的所有内容检查 - 许多软件公司都遵循这种做法。

I found it easiest to just have one repository, with sub directories for each class. 我发现最简单的就是拥有一个存储库,每个类都有子目录。 Then inside the class directories, I would make assignment folders (if assignments consisted of multiple files) or just place the files directly (for single-file assingments like papers). 然后在类目录中,我将创建分配文件夹(如果分配由多个文件组成)或直接放置文件(对于像文件这样的单文件分配)。

I use svn hosted on a home computer for all my coursework (and personal) projects. 我在家用电脑上使用svn来完成我的所有课程(和个人)项目。 Here's the layout I use for the repository: 这是我用于存储库的布局:

<SchoolName>
<SchoolName>\<className>
//assuming homework are generally single files
<SchoolName>\<className>\Homework\
//assuming multiple files needed
<SchoolName>\<className>\Assignment x- The Project of DOOM\ 
Personal\<broad non specific name>

And I find it works well for me. 而且我发现它适合我。 Not just for computer classes either: English, Math, really any class where the majority of the work will end up being typed. 不仅仅是计算机课程:英语,数学,实际上任何大部分工作最终都要输入的课程。 I can see that using svn with, say, a drawing class would be problematic. 我可以看到使用svn,比如绘图类会有问题。

I'd like to add to joeslice's comment above, another advantage of going with Mercurial (on Bitbucket, say) will be having easy access to clients on Windows/Unix/Mac. 我想在上面添加joeslice的评论 ,与Mercurial(比如Bitbucket)合作的另一个好处是可以轻松访问Windows / Unix / Mac上的客户端。

  • Go with different repositories if they don't have dependencies. 如果它们没有依赖关系,请使用不同的存储库。
  • Mercurial is pretty much init and run, but that's true for all DVCS I think. Mercurial几乎是init和运行的,但我认为对于所有DVCS都是如此。 This also means that you don't have to worry too much about how to organize things perfectly but can instead just hg init in any directory before you start working there. 这也意味着您不必过于担心如何完美地组织事物,而是可以在开始工作之前在任何目录中使用hg init

PS: I'd have left this as a comment to the post , but apparently I am not allowed to comment yet. PS:我已经将此作为对该帖子的评论,但显然我还不能发表评论。

To me, if I do not host the repository directly in my HD, I prefer to use DVCS (in this case, Git). 对我来说,如果我没有直接在我的HD中托管存储库,我更喜欢使用DVCS(在这种情况下,Git)。 For the moment, I use Bazaar as it can do both Centralised and Distributed (and swap between the two using Bind and UnBind operations). 目前,我使用Bazaar,因为它可以同时执行集中式和分布式(并使用Bind和UnBind操作在两者之间进行交换)。 I think you can use it through WebDAV too. 我想你也可以通过WebDAV使用它。 I use it through Eclipse plugin so it as easy as other VCS. 我通过Eclipse插件使用它,因此它像其他VCS一样简单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM