Introduction to installing and using GIT on Linux

Source: Internet
Author: User


GIT is a distributed version control software created by Linus Benedict Torvalds to manage Linux kernel development more effectively, unlike common version control tools such as CVS and Subversion, it does not have to be supported by server software, and the speed and efficiency are also greatly improved. If www.2cto.com has the background of CVS or SVN, the more familiar method is the client-server mode. All the file repositories are stored on the server, you need to obtain the old version from the project on the server on the local installation client and submit the new version. GIT has abandoned this mode. When a user downloads a project from a remote GIT repository, all files of the project, including version history and file changes, will be downloaded, at this time, the local GIT becomes a server, and all the commits (check-in) and commits (check-out) will be executed on this local server. After you confirm a change, it can be combined and synchronized with the remote warehouse (merge ). Therefore, the installation and configuration steps of GIT are the same on both the local machine and the server. Here, we will briefly introduce how to install and use GIT on Linux. In addition, GIT has a Windows client. 1. Download and install GIT download GIT from the http://git-scm.com/download here or use the wget command to get the $ cd $ wget http://kernel.org/pub/software/scm/git/git-1.7.6.tar.bz2 above the address if it cannot be downloaded, please download and unzip the http://download.csdn.net/detail/lovejuan007/3713236 and switch to its directory www.2cto.com $ tar xvfj git-1.7.6.tar.bz2 $ cd git-1.7.6 to use the default configuration for installation, if you want to modify the configuration, you can use. /configure -- help to get help $. /configure $ make install 2. The initial configuration GIT is installed in/usr/local/bin by default. After the installation, you can verify that $ whe is installed. Reis gitgit:/usr/local/bin/git $ git -- versiongit version 1.7.6 $ git -- help first you need to specify the user name and email address $ git config -- global user. name "GIT Admin" $ git config -- global user. emal obugs.net@gmail.com and then verify the configuration information www.2cto.com $ git config -- listuser. name = GIT Adminuser. email = obugs.net@gmail.comcore.repositoryformatversion = 0core. filemode = truecore. bare = falsecore. logallrefupdates = true in fact, these configurations are stored in the home directory. gitconfig File $ Cat ~ /. Gitconfig [user] name = GIT Adminemail = obugs.net@gmail.com 3. You can create a GIT project in any directory where the project is locally stored. If the current project is located in the/home/obugs/projects/orangebugs directory, you can define this directory as a GIT project $ cd/home/obugs/projects/orangebugs $ git initInitialized empty Git repository in/home/obugs/projects/orangebugs /. git/creates a file named. git folder, which is the folder that GIT uses to store information and track changes. Www.2cto.com $ ls-altr. gittotal quota 4 git 4096 Aug 13 refsdrwxrwxr-x 4 git 4096 Aug 13 objectsdrwxrwxr-x 2 git 4096 Aug 13 infodrwxrwxr-x 2 git 4096 Aug 13 hooks -rw-r -- 1 git 23 Aug 13 HEAD-rw-r -- 1 git 73 Aug 13 description-rw-r -- 1 git 92 Aug 13 configdrwxrwxr-x 2 git 4096 Aug 13 branchesdrwxrw Xr-x 36 git 4096 Aug 13 .. drwxrwxr-x 7 git 4096 Aug 13. 4. add and submit files to the project. These operations are similar to those of CVS and SVN, such as $ git add *. java *. c $ git commit-m'initial upload of the project 'create mode 100755 Orangebugs. javacreate mode 100755 pwm/ui/DataManager. javacreate mode 100755 pwm/ui/PasswordFrame. javacreate mode 100755 pwm/tools/StrongEncryption. javacreate mode 100755 pwm/tools/PasswordStrength. java .. note: If you have not used git config to specify the user name and email address, the error $ git commit-m' Initial upload of the project *** Please tell me who you are. www.2cto.com Run git config -- global user. email "you@example.com" git config -- global user. name "Your Name" to set your account's default identity. omit -- global to set the identity only in this repository. fatal: empty ident not allowed 5. Modify the file and submit the modified editing file. Some fields are added or deleted. java View the changes compared to the files in the GIT repository $ git diffdiff -- git a/Orangebugs. java B/Orangebugs. javaindex 6166ed1 .. fd82d32 100644-a/Orangebugs. java ++ B/Orangebugs. java @-+ @-public counter = 10 + public counter = 55 if you want to submit the file, make sure that the file is added to the temporary area before submission, the Default Editor of the system is automatically opened when the system is submitted. When you add comments and save them and exit the editor, these comments are submitted to the repository at the same time for www.2cto.com $ git add Orangebugs. java $ git commit [master 80f10a9] Added password strength meter funct Ionality1 files changed, 56 insertions (+), 7 deletions (-) or, simply use git commit-a to merge the preceding two commands into one. 6. View status and view comments. If the local file is not changed compared with the file in the remote GIT repository, $ git status # On branch masternothing to commit (working directory clean) if a local change is made but not submitted, $ git status # On branch master # Changes not staged for commit: # (use "git add ..." To update what will be committed) # (use "git checkout -..." To discard changes in working directory) # modified: Orangebugs. java # no changes added to commit (use "git add" and/or "git commit-a") in addition, you can use the following command to view the file history and previous comments $ git log Orangebugs. javacommit c919ced7f42f4bc06d563c1a1eaa1_f2b2420d5author: GIT Admin www.2cto.com Date: Sat Aug 13 22:54:57 2011-0700 Added password strength meter functionality commit limit: GI T AdminDate: Sat Aug 13 20:08:02 2011-0700 Initial upload of the project author ..

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.