Build a git server on Ubuntu and use xcode to connect to it on MAC for development.

Source: Internet
Author: User

I searched for it at night. After a long time, I finally got it done. All kinds of problems have been encountered before, and there is nothing special. I need to feel that I really need to calm down and read the [tutorial/Guide] Before I start. It is often because you encounter problems and go back to the information to find that you have missed or understood the error. The more worried you are about configuring the environment, the less you will be able to succeed. After the review, I concluded that only by understanding the true meaning of each command and the internal process of program work can we know ourselves and know ourselves! 1. [Build a git server on Ubuntu]: This article mainly refers to the following. Remove unnecessary steps and explain the original text clearly. [Explanation of how git programmers work] on the hardware, we have a [git server] (a computer) based on this situation ), it is used to manage source code. Then, several developers collaborate on different [clients], and upload their modified source code to the [git server] for unified management from time to time. [What hardware is required to build a git server ?] One Ubuntu computer, my desktop version is 10.04 ~ Perform the following steps: 1. create a new user named git to manage the GIT Server: sudo uderadd-M git // here-M means to create both the home directory and the mail directory sudo passwd git when creating a user // create a password for the GIT user (GIT name is Ubuntu. It is different from the user name you give yourself. Once the GIT user name is created, the user needs to manage the GIT server. So you can see that when you use the su git command to convert your account. The prompt displayed on the terminal is different from your original prompt! By default, there is no Bash to complete this useful thing! Alas .) (I think it is unnecessary to create a directory as a git repository. On the contrary, if you create a git repository, you can directly generate a git repository under the git home directory! We will introduce how to generate a git repository later .) 2. Install git and OpenSSH on Ubuntu. Just run sudo apt-Get install Git-core openssh-server openssh-client. So far, our git program has been installed. We can use commands like "Git clone" to remotely request respositories (GIT repository ). We will see later that we are using git clone to download the GIT management tool gitosis. Before downloading gitosis, initialize the following git users: git config -- global user. name "myname" Git config -- global user. after email "myname@gmail.com", each time the commit is submitted, the two messages will be uploaded to the server as they are submitted. Mark who submitted each submission and how to contact him. This file will be written in "~ /. Gitconfig "file, you can modify it later. 3. install and configure gitosis. Gitosis is a tool that facilitates the management of git services. First install Python's setuptool, because this tool is required when gitosis is installed. Sudo apt-Get install Python-setuptools. Next, we will install gitosis. As mentioned above, we need to use git clone to request the gitosis repository. First, go to the/tmp directory. (This is the temporary directory of ubuntu ~ Next time you start the system, nothing will be saved in the temporary storage, so we will download the gitosis Installation File here and discard it after installation. Giggling ~ Wow, I think of it !) In the/tmp directory, run the following command: git clone git: // eagain.net/gitosis.gitexample to download the gitosisinstallation file. Go to the gitosis directory. Run sudo Python setup. py install to complete gitosis installation! 4. Install gitosis. On our Ubuntu server (actually a PC), we have all the features of git. (I have read about git and know that git does not have the concept of a server or a client. Each Server is a client and each client is a server. So why should we call this PC a server? Because we are developing iOS programs and won't develop them on Ubuntu. We only use Ubuntu for source code control, so this Ubuntu computer is assigned the mission of server. So we have built the GIT server. Now we need a user to manage this server. You may say, A. Git users can manage it. However, we generally do not directly operate the GIT server because it may be stored in a distant place, such as a locked data center. How can we manage the [git server. The answer is: we can manage the [git server] on [client ]! First, let's say goodbye to the [git server] PC. Now we have to switch to the [client] for work. Our client is a Mac Pro computer. Let me name him "Mini pro" for now. On [small pro], type: (usually in the home directory) ssh-keygen-t rsa and press Enter. At this time, a ". Ssh" folder is generated under the Home Directory, which is hidden! This command is used to generate a pair of "public key and Private Key". The private key is placed on "small pro, the public key must be obtained on the [git server. So that the [git server] recognizes [small pro] as its administrator! Just as a piece of jade is divided into two halves, and you and I are half done as a matter of confidence! Haha. On the premise that the [small pro] can ping the [git server], we adopt: SCP. SSH/id_rsa.pub git @ <server's ip>:/tmp replace <server's ip> with an IP address like 172.16.23.85. After successful. Let's go back to the GIT server. Well, let's also name the GIT server [little git. In the future, I will not play [] again. It is very troublesome. 5. Now we will add the Public Key uploaded to the GIT management list. As follows: sudo chmod A + R/tmp/id_rsa.pubsudo-H-u git gitosis-init </tmp/id_rsa.pub, git generates the [gitosis] [repostories] folder under the/home/git/directory ]. [Repositories] is the GIT repository folder! Including configuration files that can change git is also put in this repository folder called "gitosis-admin.git ". First, create a root account: su passwd root, then log on to the root account: su root, and then change a file to readable and executable. In this way, git configuration can be managed from the remote end. Command: sudo chmod 755/home/git/repositories/gitosis-admin.git/hooks/post-update6. So far I can configure little git through little pro. However, while we are still on small git, let's first create a new repository for the test project. As follows: su git // switch to a git account. Do not think it is useless to create this account. CD/home/git/repositoriesmkdir infoboard-ios.gitgit init -- bare // -- bare is used to initialize an empty folder as a git repository 7. Well, now we can go back to the little pro. Enter git clone git @ <Server> in the directory where you want to place the GIT configuration Repository: gitosis-admin.gitcd gitosis-admin.git the keydir directory under this directory is used to store the SSH Public Key for all users who need to access the GIT server. Now you can see that there is only one pub file, which is your SSH public key. Suppose it is called "Xiao fan's little pro. Pub ". To add other users to the GIT Project Development Permission list. Each user needs to generate their own SSH public key file according to the method mentioned above, take all the SSH Public Key Files and name them by name, such as "James. pub "," small red. pub ", etc., all copied to the keydir. In addition, open gitosis. conf, most of which are like this: [gitosis] [group gitosis-admin] writable = gitosis-adminmembers = Xiao fan's Mini pro where "Xiao fan's Mini pro" is the pub file in the previous keydir file with the remaining suffix name removed. If you have obtained the pub file of James, you should first change it from "id_rsa.pub" to "James. pub ", then enter the keydir, and modify gitosis. conf, changed to [gitosis] [group gitosis-admin] writable = gitosis-adminmembers = Xiao fan's small pro James is OK. If you want Xiao fan and James to manage the warehouse of infoboard-ios.git at the same time. The configuration file should be changed: [gitosis] [group gitosis-admin] writable = gitosis-adminmembers = Xiao fan's little pro James [Group infoboard-Ios] writable = infoboard-iosmembers = Xiao fan's little pro James so OK pull. If you want someone to read only, modify writable to readonly. Of course, the modifications to these configuration files are only made locally. You must push them to the remote gitserver to make the changes take effect. Add new files, submit and push to the GIT server: first make sure you are under the gitosis-admin.git directory. Then, git add. git commit-am "the comments you want to add" git push git @ <gitserver>: After the gitosis-admin.git is uploaded successfully, all the users you set can access the GIT repository. 8. Add the existing infoboard-Ios project to/home/infoboard-IOS. First, you first enter the directory of this project. Git initgit add. git commit-am "initial version" git push git @ <gitserver>: infoboard-ios.git attention, here the infoboard-ios.git repository must be created on the server side first Oh, otherwise it is not push up. 9. Use xcode4 to check out projects from the GIT repository for development. Open xode4, select connect to a repository, and fill in the server Mailing address: Here, gitserver is the alias I added for the IP address in/etc/hosts. The added code is as follows: 172.16.23.85 gitserver and then it is very simple. Thanks to xcode's built-in git, version control has become so simple. Postscript: For more information, see the original document. There are also some small tips: 1. after the USB flash disk is inserted into the Mac, it is mounted to the/volumes/directory by default. 2. restart the SSH service: sudo/etc/init. d/ssh restart or sudo service SSH restart3. Remote Server repository can be developed for short: for example, after using git remote add infoboard git @ gitserver: infoboard-ios.git, you can use git push infoboard to directly put infoboard. git repository push server Delete Remote Server Abbreviation: git remote RM infoboard4. SCP is used. when ssh/id_rsa.pub git @ gitserver:/tmp appears: Permission denied (publickey), modify passwordauthentication from no on the server side Change to yes and restart ssh. In the sshd_config file, you can also set many SSH parameters. 5. In ubuntu, let the terminal display only the current directory name: Modify ~ /. Bashrc: Change the lower case w after if ["$ color_prompt" = Yes]; then · to upper case W. 6. ubuntu for the desktop version does not have apache2. you can install it with APT-Get install. in Mac OS, there is a very convenient screenshot shortcut: Command-shift-3: For the entire screen screenshot, the picture will be saved in a file (the default saved desktop) Command-Ctrl-Shift-3: screenshots of the entire screen are saved to the clipboard. Command-shift-4: screenshots are taken from the selected area and the images are saved to the file (the desktop is saved by default ). After the shortcut key is triggered, press the Space key to take screenshots of an entire window or menu. Command-Ctrl-Shift-4: screenshots of selected areas are saved to the clipboard. These shortcut keys are all set by default. We can modify these shortcut keys. Go to "system preference settings"> "mouse and keyboard"> "shortcut key", and modify it in the "screen snapshot" section. 8. Reset the previous committed commit: git reset -- hard head ~ 1. After resetting, the previous committed commit will disappear. However, after resetting, there may be problems in push. 9. steps for pushing a project to the server for the first time: 1) create a project directory named XXX on the server using the GIT account mkdir. git2) Go to this directory and execute git init -- bare: Create an empty repository 3) with a client with permissions, through the pull gitosis-admin.git, and modify it, then push to create user permissions, to modify keys under the giosis-admin.conf and keydir Directories 4) Go to the client project directory and delete all the previous project repositories, that is. git and other hidden files. Run: git init and git add. and git commit-am "XXX", and then use [git push git @ gitserver: infoboard-hd.git master], note that the first push must be added to the master set this is the main branch. Reference: http://www.newsmth.net/pc/pccon.php? Id = 10003915 & nid = 433174 & pid = 0 & tag = 0 reprint: http://fanguoheng.42qu.com/po/blog/10496087

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.