1. Git is a distributed code version management tool. Similar common tools are SVN and CVS. The biggest feature is also the advantage of providing distributed code management
1. There is only one branch code!
Children's shoes that have used svn must know that when we want to develop a new function or add a new version or modify a complex bug, we usually need to copy the entire code to a local directory and then add it to the svn server for code management.
Unlike Git, Git can create many branches, and each branch is independent. When we need to modify the code, the commit is only a modification of the local repository. If you use SourceTree, we will find that the Git Flow function in the toolbar has been well prepared for this.
2. The log is local!
SVN logs are stored on the server. When we want to check the modification records, we must be able to connect to the remote server and have permissions. Unlike Git, Git's modification records of the local warehouse are all on the local, which is convenient for reference.
3. Merge code is more convenient!
Because Git supports local unlimited branches, when we individually create multiple branches locally for different purposes (modify, add, explore), it is obviously easier to merge a code than svn to merge a bunch of engineering copies.
4. Safer!
Git's commit command is different from SVN. Commit is just an update to the local repository code. When you need to submit to the master remote warehouse, or other remote branch warehouse, you need to use the push function. Although a process has been added, it can prevent the risk of random changes causing major problems in later mergers. When the user is working, modify the file from the local repository (modified), write to the git temporary area (staged), and submit the contents of the temporary area to the local warehouse (committed). This series of work is carried out on the local warehouse of the user's machine. Before you push the local warehouse to the warehouse on the remote server, there is no work in the remote warehouse.
5. The directory is more concise!
In the root directory of the Git local repository, there is only one .git file, which contains all management information. And SVN presumably everyone knows that there are disgusting .svn in each subdirectory. When you need to modify file conflicts and other issues, you need to consider it. It must be a simple file.
2. Installation
Before proceeding with the installation, let me say that, like SVN, both need to create a server, and they can all create their own version management servers. For individuals and small teams, using a hosted server may be more appropriate.
Common ones are Github and Bitbucket. There is no personal free repository for Github, and the code is open source. Bitbucket's personal warehouse related pages have been basically finished. The registration process is also relatively simple.
The best GIT free GUI tool on MAC is SourceTree (no one). In addition, the best open source website for GIT code is GitHub, and the best private library for GIT code is BitBucket.
Installation process:
1. Download Git installer, address; http://git-scm.com/downloads
2. Open after downloading, double-click .pkg to install
3. Open the terminal, use git --version or which git command to view the installation version, if it is installed successfully
4. Create a global username and global mailbox
git config --global user.name "shengyao"
git config --global user.email "MY_NAME@example.com"
5. Open the terminal after successful installation
cd ~ enter the root directory
Enter the command ssh-keygen to generate ssh-key, if prompted, keep pressing Enter
technology sharing
6. Add the SSH key to GitHub. Log in to the GitHub page, Account Settings-> SSH Public Keys-> Add another key
Copy the content of the generated key (id_rsa.pub file) to the input box and save.
commd + shift + g enter /Users/chen/.ssh/ to see the private key and public key
The name of the private key is id_rsa, which is the only credential that the server determines your identity.
The name of the public key is id_rsa.pub. Send this file to the warehouse administrator. The warehouse administrator will put the public key on the server, and git will interact with the server through the private key above. If you use github, you add the public key content yourself
7. Find a directory and execute git clone http: //xxx.git (clone the git library from the server side, of course, this requires the server administrator to give you permissions and account), the xxx directory will be a git directory in the future, you can execute under this directory git operation
Three, linux basic commands
sudo -s get absolute user permissions
cd xxx into the xxx directory
ls (-a / -A) display all files in the current path (hidden)
pwd displays the current absolute path
mkdir xxx create folder xxx
man xxx View xxx command manual
Then introduce the meaning of Git basic commands;
clone clone remote repository
init initializes the warehouse
remote connect to remote warehouse
pull pull new data from a remote warehouse
push upload new or modified files from the local warehouse to the remote warehouse
add add files or modify files, used before commit and push
log The log information submitted by the current warehouse
status Current warehouse version status
commit to the current warehouse
branch branch command, related addition and deletion check operations
checkout Use the last version of the remote warehouse to completely cover the current warehouse content / select the branch branch
diff comparison version content
merge merge version content
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.