Hiển thị các bài đăng có nhãn SVN. Hiển thị tất cả bài đăng
Hiển thị các bài đăng có nhãn SVN. Hiển thị tất cả bài đăng

Thứ Hai, 15 tháng 3, 2021

SVN Cheat Sheet

 1. Basic Work Cycle

Update to the latest revision checkout, update
Do your work, change files add, remove, copy, move
Examine changes status, diff, revert
Merge your work update, resolved
Commit commit -m "your comment"


2. Create a repository
svnadmin create /path/to/repo


3. The Working Copy

Get a working copy (= checkout) svn (checkout|co) [-r REV] url://repo/path/ path/to/project
Update your working copy *1 svn (update|up) [-r REV] [path/to/project]

Add a file/directory to the project (!= import) svn add path/to/fileOrDirectory
Copy a file/directory and mark it as added svn copy path/to/fileOrDirectory path/to/newCopy
Rename/move a file/directory svn (move|mv|rename|ren) path/to/dir path/to/newDir
Delete a file/directory svn (delete|del|remove|rm) path/to/fileOrDirectory
Lock (or unlock) a file/directory for editing svn (lock|unlock) path/to/fileOrDirectory

Check the status of your local file(s) *2 svn status [path/to/fileOrDirectory]
Compare the status to the repo *2 svn status -u [path/to/fileOrDirectory]
Do a diff of your file(s) and the repo svn diff [-r REV] [path/to/fileOrDirectory]
Revert to last revision (last checkout or update) svn revert [path/to/fileOrDirectory]
Resolve conflicts (after you reviewed them!) svn resolved [path/to/fileOrDirectory]
Commit and create a new revision svn (commit|ci) [path/to/project] -m "your comment"

Import unversioned files/folders *3 svn import path/to/original url://repo/path/
Show a log svn log [-r REV] [path/to/fileOrDirectory]
Concatenate a specific file svn cat [-r REV] path/to/file



Thứ Năm, 28 tháng 7, 2016

Git va SVN

Rất nhiều nhà phát triển đã từng nghe về cái gọi là version control, nhưng họ có thể không biết đầy đủ về chúng là cái gì và lợi ích của chúng trong quản lý dự án của họ như nào. Trong bài viết này chúng ta đi tìm hiểu lợi ích công việc với version control và sự khác nhau giữa GIT và SVN, những cái version control được dùng nhiều nhất hiện nay.Phương án đơn giản nhất để giải thích Version control là sử dụng các kho dự án file cùng nhau với lịch sử của các mã nguồn của bạn trong cùng một vị trí. Điều này làm cho những nhà phát triển dự án theo dõi mỗi sự thay đổi tạo ra với mã nguồn, những ai làm thay đổi và lý do thay đổi.
Những file đó bình thường sẽ nằm trên một vài server từ máy tính của những nhà phát triển, sau đó họ đẩy những file của họ lên khi hoàn thành việc gõ xong mã nguồn.
Nó cũng cho phép bạn đánh dấu mã nguồn của bạn vào thời điểm đó, tạo dễ dàng quay trời lại thời điểm đó nếu những tính năng mới đó làm đổ vỡ mã nguồn của bạn. Version control có thể cũng có lợi cho nhà phát triển độc lập(một mình) trên dự án của họ và nó cần thiết cho đội những nhà phát triển làm việc trên cùng một dự án.

 TẠI SAO PHẢI SƯ DỤNG VERSION CONTROL?

Version control là cần thiết khi làm việc cho đội phát triển, nếu bạn đang làm với đội phát triển và không có version control, chắc chắn bất kì một ai đó sẽ dừng công việc bởi không biết ai làm cái gì và đọc điều đó ở đâu.
Nếu bạn không có version control, phương án duy nhất bạn có thể làm việc là chia sẻ mã nguồn của bạn trên các nơi lưu trữ có thể và bạn có thể truy cập tất cả file mã nguồn đó để thấy những thay đổi đó. Nhưng mọi thứ đều làm công việc đi sai hướng, đầu tiên là không có từ hai nhà phát triển làm việc trên cùng một file ở cùng một thời điểm. Nếu hơn hai nhà phát triển làm việc trên nó, người cuối cùng lưu lại sẽ vượt quyền thay đổi những mã nguồn của người khác. Sử dụng version control giúp cho nhiều nhà phát triển làm việc trên một file ở cùng một thời điểm, khi họ đã hoàn thành những thay đổi mã nguồn, họ có thể commit chúng trở lại kho mã nguồn. Khi bạn đã commit file quay trở lại kho, nó sẽ trộn lẫn những thay đổi đó trong version control.
Vấn đề thứ hai đó là không có lịch sử mã nguồn vì vậy nếu bạn tạo ra một tính năng mới và demo nó với khách hàng và họ quyết định họ không muốn nó nữa, bạn sẽ phải đi tới mã nguồn và xóa đi những thứ mà bạn đã làm. Nếu bạn đã sử dụng version control bạn có thể sẽ lấy lại mã nguồn trước khi phát triển những tính năng mới đó.
Vấn đề thứ ba cho việc bạn không thể sử dụng thiếu version control đó là tính năng “trách nhiệm”. Version control sẽ ghi lại ai đã viết ra các phần mã nguồn, điều đó có nghĩa là với nhũng phần mã nguồn mà bạn không biết tại sao nó ở đây, bạn sử dụng version control để kiểm tra mã nguồn để nói với bạn, nhà phát triển nào viết điều đó vì vậy bạn có thể hỏi nhà phát triển đó giải thích lý do tại sao họ làm điều này.
Tagging là một tính năng quan trọng bạn cần có để nâng cao khi làm việc với versioncontrol.Khi bạn hoàn thành với một phần công việc và sẵn cho việc triển khai mã nguồn, bạn sau đó tag phiên bản mã nguồn đó. Điều đó là cần thiết cho việc tạo ra các nhánh mã nguồn khác nhau ở thời điểm tạo đó. Sau đó bạn có thể triển khai mã nguồn với những tag đó, cho phép bạn trích xuất ra mã nguồn đó mà bạn có trên máy chủ. Lợi ích của điều này nếu có vấn đề với phiên bản phát hành hiện tại đó, bạn có thể dễ dàng quay trở lại thời điểm tạo ra tag đó.

LỰA CHỌN VERSION CONTROL

Bây giờ bạn đã hiểu những lợi ích của việc sử dụng version control, nhưng giờ bạn sẽ lựa chọn cái nào để dùng?
Có nhiều kiểu phiên bản version control, ở đây chúng ta sẽ xem xét hai version control hay dùng và phổ biết nhất hiện nay là Git và SVN. Bạn có thể thấy chúng khá giống nhau, nhưng phương án làm việc của hai cái đó là khác nhau hoàn toàn. Không có cái nào là tốt hơn cái nào, nó tùy thuộc vào việc bạn sẽ học nó và phục vụ cho công việc của bạn, cũng như cái gì bạn muốn sử dụng nó.

SVN

SVN or Subversion là một trong những version control được sử dụng phổ biến hiện nay, nó dễ hiểu và rất rõ trong các luồng công việc. Hiện tại kho plugin WordPress sử dụng SVN.
Nó làm việc với một máy chủ trung tâm kho mã nguồn, những kho đó là được chia vào 3 key chính đó là Trunk, Branches(nhánh), tags. Mỗi cái đều có vai trò quan trọng của riêng chúng.
Trunk
Cái này là nơi lưu trữ mã nguồn gốc, nó sẽ không được commit các phần mã nguồn vào trong đó, nó giống như khu vực trung tâm nơi bất cứ ai làm việc trên dự án sẽ lấy các cập nhật tại đây. Khi bạn làm việc với một tính năng mới bạn sẽ branches (nhánh) mã nguồn từ trunk, khi bạn gõ mã hoàn thành tính năng mới đó, sau đó bạn sẽ merge tất cả những thay đổi đó vào trunk.
Branches
Như giải thích ở trên branch(nhánh) là sử dụng khi bạn tạo ra một tính năng mới, vì vậy bạn branch mã nguồn từ trunk. Điều này nghĩa là bạn có thể lấy ra bản sao chép trunk và đặt điều này vào trong một folder mới bện trong khu vực branch. Bây giờ bạn có thể làm việc trong đó với việc tạo ra tính năng mới của bạn, sau khi hoàn thanh bạn sẽ merge những thay đổi đó vào trong trunk.
Lợi ích của điều này giúp cho bạn phát triển tính năng mới mà bạn có thể commits vào trong branche(nhánh) và bạn có thể không làm đổ vỡ trunk cho một ai đó khác làm việc trên cùng dự án., nó giữ cho trunk ổn định nhất có thể.
 Tags
Tag là phương án tạo mã nguồn của bạn vào một thời điểm nào đó, nó giống như branch làm với mã nguồn của bạn. Chúng sẽ làm điều đó với một bản sao chép từ mã nguồn trunk và đặt nó vào bên trong một folder mới với thư mục tag. Sự khác nhau đó là tag sẽ không bao giờ sử dụng cho phát triển mã nguồn, chúng là phưong án dễ dàng cho việc lấy lại mã nguồn của bạn.
 Thời điểm khi sử dụng tag là cho việc triển khai mã nguồn, khi bạn hoàn thành những mã nguồn mới, mereg vào trong trunk, test đầy đủ và sẵn sàng cho việc phát hành, khi đó bạn sử dụng tag. Bạn sẽ tạo tag trên trunk và đánh dấu tính năng mới đó, bạn có thể nắm giữ tag và triển khai nó tới máy chủ của bạn. Lợi ích làm điều này là nếu bản phát hành mới đổ vỡ, bạn có thể lấy lại mã nguồn quay trở lại thời điểm tag trước đó.

GIT 

Thời điểm này GIT là một version control phổ biến và hay dùng nhất, bởi sự phổ biết của website Github. Giống như trước đây đã đề cập GIT và SVN là khá giống nhau nhưng luồng công việc là có chút ít khác nhau. SVN là chỉ có một kho trung tâm, nhưng GIT có đa kho, tức là một kho trung tâm những mỗi nhà phát triển có những kho riêng của họ.
Lợi ích cho việc chia nhỏ đó vào trong nhiều kho mã nguồn đó là sự hỏng hóc ở một chỗ nào đó. Với SVN nếu kho trung tâm là bị hỏng hoặc mã nguồn bị đổ vỡ sau khi phát triển, thì không một nhà phát triển nào khác sử dụng cho việc commit mã nguồn của họ cho đến khi kho được sủa chữa lại. Với GIT thì mỗi nhà phát triển đều có một kho riêng của họ, nó không phải là kho chính nếu kho chính bị đổ vỡ, họ có thể tiếp tục commit mã nguồn trên kho cá nhân , cho đến khi kho chính là được sửa và sau đó họ có thể đẩy mã nguồn của họ vào trong kho chính đó.
 Một lợi ích khác là kho cá nhân đó là commit nhanh, không mất băng thông mạng cần cho việc commit mã nguồn vào trong source control, những nhà phát triển có thể làm việc độc lập cho đến khi sẵn đẩy mã nguồn tới kho chính.
Luồng công việc mà bạn sử dụng khi phát triển với việc dùng GIT như sau:
 Khi làm việc trên dự án bạn sẽ sao chép bản sao mã nguồn từ kho chính, có nghĩa rằng bạn có thể tạo ra một bản sao mã nguồn ở thời điểm đó. Điều này tạo ra một kho GIT cục bộ trên máy tính cá nhân của bạn, nơi bạn có thể tiếp tục công việc cho việc phát triểnt tính năng mới. Bạn có thể sử dụng kho cục bộ đó như sử dụng nó như sử dụng SVN đó là tạo branche mới , tags mới và tiếp tục commit mã nguồn lên kho cục bộ trong khi phát triển.
 Khi tính năng mới của bạn hoàn thành và bạn sẵn merge những thay đổi đó vào trong kho chính bạn cần đẩy những thay đổi đó lên từ kho cục bộ của bạn tới kho chính. Đây chỉ là phần ít sử dụng nhất trong GIT và nó tương tự như commit trong SVN, nhưng bạn sẽ không thường sử dụng commit và sử dụng commit trong GIT nhanh chóng.

Thứ Năm, 12 tháng 9, 2013

Setup SVN in Ubuntu Server

1. http://oliverdavies.co.uk/blog/2011/10/install-and-configure-subversion-svn-server-ubuntu
2. https://help.ubuntu.com/community/Subversion
3. https://help.ubuntu.com/10.04/serverguide/subversion.html

4. http://stackoverflow.com/questions/60736/how-to-setup-a-subversion-svn-server-on-gnu-linux-ubuntu

5. http://www.howtoforge.com/installing-subversion-and-configuring-access-through-different-protocols-on-ubuntu-11.10

6.

So, I've been playing about with setting up SVN quickly and semi secure on a Ubuntu server recently.  SVN, because I don't mind it as a server technology, it has its benefits over nothing, and it of course has its own faults compared to other source and revision control software.  Indeed, its major selling point for me was simply that I have been using it commercially at work for the best part of four years.

However, previously I've always set it up on Kubuntu, with KDE to help me out, what became apparent recently (on my Dell servers) was that I had no GUI, I needed to get back to the command line to install this software.

Also some of the examples out there on the Internet already make a real mess of using CHMOD and other tricks to move the folders around, and some of them reference htpasswd2, when you need to use htpasswd2 on Ubuntu Server 10.04 and above.

So, here are my set of commands, each with a little blurb about them, to help you use just the command line on Ubuntu Server to set up SVN via Apache2.

Prerequisites
1. Ubuntu Server ISO (on CD or DVD) to install onto your server or Virtual Machine.
2. Internet connection.
3. If you want to use SSH to lock your noisy server in a cupboard and administer it from a PC get Putty and follow step XX below.

Set the server up
Install your server.  I chose Ubuntu 11.04 64bit for my machines and installed from a CD.  I set it up as I wanted, the only thing I did was when prompted to choose to install LAMP or Apache etc etc, I chose nothing, I just started from the blank server.

Hmm looks like Visual Studio stuck a comment into my screen shot - ignore that,
make sure you have nothing picked in the DOS looking terminal style text.

Also, remember to set your password and username for root... and at this point... make sure the root password and username is NOT going to be one of the usernames which can access SVN [that's just a bit of basic security common sense].

So, my root for this demo has a username "mega" and my password is "maniac".

Once your server is up, and you are presented with the log in prompt come back to the sequence below.

Set up SSH
Log into your server, physically in front of it, so i type "mega" and then "maniac" and I get into the prompt, and the first thing I need to do is install the SSH server, so I can get to the machine over the LAN, or WAN.

Now, I don't want this service to automatically start, so we're just going to start is here once its installed.  So, to install the open SSH server type:

sudo apt-get install openssh-server
This will tell the system to act as the super user to use aptitude to install the package we want.  Type that in and when is asked for the sudo password for your root type in your password, so I now type "maniac".

The system will remember your sudo password for a short while now, so for the next few commands you won't be asked for the sudo password, but after that duration you will start to be asked for the sudo/root password again.  Don't worry, this is normal.

Once you've entered your password the system will go out onto the Internet and look for the open ssh server package, for me this tells me it needs to download just over 1megabyte of data, so I select yes and let it complete.

Once that is all complete, you need to start the server with the command:

sudo /etc/init.d/ssh start

When it is complete you should see the message:

* Starting OpenBSD Secure Shell server sshd     [ OK ]

If not, then you'll need to go out onto the Internet and see who can help you.  But if you're lucky enough to see the "OK" its time to exit from your shell in front of your noisy server, close the server room door and nip up to your quiet PC somewhere else.  Before you go though you may want to use the command "ifconfig" to tell you the IP address your new server is on.

So, once you're back at your desk, you need to run an SSH capable terminal program, I prefer "PuTTy" from http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html because you can scroll up and down in your prompt window, where as from the actual machine you'll find stuff disappearing off the top.

So, fire up the terminal program of your choice and connect to the server SSH server you set running.

Installing Apache & Subversion
Now we need to install the three packages which allow us to use and host SVN on the machine, these are SVN itself, Apache2 as our web server and the library to link apache to SVN.  So type:

sudo apt-get install apache2 subversion libapache2-svn

This should be just shy of 18 megabytes in size, depending on your situation, so let it complete.

Now, fire up a web browser and just check the apache server is running, you should have seen "* Starting wen server apache2   [ OK ]" scroll past, so we'll just check.

Type into the browser address bar "http://" and the IP address of the server and hit Go.  You should see the standard "It works!" message from apache2.  If not, well something went wrong, again I'm not trying to trouble shoot for you just show you a way that works, and has worked, multiple times for Ubuntu Server.

Create your Repository
The next thing we need to do is set up the subversion repository.  Lots of other tutorials and examples on the internet recommend putting the repository in strange exotic paths, which require CHMOD and alsorts of stuff being performed on the folders to give Apache access to them.  We're not going to bother with that, we're just going to stop the folders being accessed from the browser by NOT creating our repository in the www folder.  Don't ever do that!

So, now create the repository with:

sudo svnadmin create /svn

This will create our svn repository in /svn off of the root of the disk.  Remember that path, we'll need it in a moment.

Set apache to host Subversion
Now we need to edit the apache2 module which points to SVN for us to point at this new repository.  So we need to do some editing of text, other places use other tools, but I prefer nano as my text editor.

So, lets edit the first file, which is the config file:

sudo nano /etc/apache2/mods-enabled/dav_svn.conf

And it should come up looking just like this:



Now, the lines of text in this file can be "commented out" by adding a # at the front of them, as you see everything in this file is commented out... so we need to uncomment some lines by removing the # from the front.

So the lines to uncomment are:


< Location /svn >
DAV svn

SVNPath /var/lib/svn

And with this path line, change this to the path we created earlier.  So I'm changing mine to read:

SVNPath /svn

The next items to uncomment are:

AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /etc/apache2/dav_svn.passwrd

This path for the user file is important, it is the file to the list of users able to access your repository, so we'll be using that in a moment!

And the final things to uncomment are:

Require valid-user

and


< / Location >


(Ignore the spaces in the / Location stuff, they're only there as blogger thinks they're tags in the HTML)


You may see the Limit Except items around the require valid-user, I however am putting my SVN on the Internet, so I do not want to allow anonymous read, I therefore just want all users no-matter what they do, to have to enter their username and password.

So, with all that edited, you need to press "CTRL+O" to Write out the file in nano, you'll be presented with the filename you are writing, press enter if it is /etc/apache2/mods-enabled/dav_svn.conf.  And then press "CTRL+X" to exit.

Create SVN Users
Next we need to create at least one user who can access our repository.  So back on the command line again we need to type:

sudo htpasswd -cm /etc/apache2/dav_svn.passwd < USERNAME >

Where the "< USERNAME >" is the username they want, it will then ask you to enter a password for this person twice.  Remember, make this password something different to your root/sudo user.  For my SVN this is "svnguy".


sudo htpasswd -cm /etc/apache2/dav_svn.passwd svnguy

The parameter -cm means to "Create" and to encrypt the file as "md5".

Later, if you just want to add a user do not specify the "c" flag, as you do not want to create the file again, you just want to encrypt the password file, so you do:

sudo htpasswd -m /etc/apache2/dav_svn.passwd < USERNAME >

Restart Apache
Lastly we need to restart Apache, so type:

sudo /etc/init.d/apache2 restart

Finally, check its working

Now, we need to check our repository is working you need to jump back to your browser and where you had "http://" you need to add /svn onto the end of the URL.  You should be prompted for the secure logon, so enter one of the people you added with htpasswd and their paddword.  And voila, you should see your working SVN server ready for you to checkout and add code to.

Thứ Hai, 15 tháng 10, 2012

Installation SVN For ECLIPSE

Option 1 - Use an Eclipse Simultaneous Release Update Site

This method is recommended if you wish to install a stable Subversive version that is an integral part of the yearly Eclipse Simultaneous Release. It allows you to install the Subversive plug-in using an Eclipse update site for an Eclipse Simultaneous Release.

    Run Eclipse and select Help > Install New Software... from the main menu.
    On the dialog that appears, select a pre-configured simultaneous release update site in the Work with combo-box. For example, for the Juno release, select the "http://download.eclipse.org/releases/juno" update site.

    Wait a few seconds until the content of the selected update site is displayed under the combo-box.
    Expand the Collaboration group and select the Subversive features that you would like to install. Certain Subversive features are required if you want to work with SVN, others are optional and offer some additional functionality. You can skip the optional features, if you wish.
    Follow the next steps to install the selected Subversive features using the standard plug-in installation procedure. Reboot Eclipse after installation is complete.
    Follow the instructions below to install Subversive connectors.

Option 2 - Use a Subversive Update Site

You can install Subversive using its online or archived update site. Use this method to install the Early Access Build that isn't available in the Eclipse Simultaneous Releases.

    Run Eclipse and select Help > Install New Software... from the main menu.
    In the Install dialog that appears, press the Add... button and specify the path to an online or archived Subversive update site. You can find information about the available Subversive update sites on the Downloads page.
    Select the required Subversive features to install and follow the standard plug-in installation procedure. Reboot Eclipse after installation is complete.
    Follow the instructions below to install Subversive connectors.

Học lập trình web căn bản với PHP

Bài 1: Các kiến thức căn bản Part 1:  https://jimmyvan88.blogspot.com/2012/05/can-ban-lap-trinh-web-voi-php-bai-1-cac.html Part 2:  https://...