Git is a distributed versioning system (distributed version control systems, or DVCS) clients that do not only extract the latest version of the file snapshot, but instead completely mirror the original code repository. As a result, any server that works together fails and can be recovered using any of the mirrored local repositories afterwards. Because each fetch operation is actually a full backup of the code warehouse at one time. Further, many of these systems can be specified to interact with several different remote code warehouses. With this, you can collaborate with people from different working groups on the same project. You can set up different collaboration processes as needed.
Git's basic workflow:
1. Modify some files in the working directory.
2. Make a snapshot of these modified files and save them to the staging area.
3. Commit the update to dump the file snapshot saved in the staging area to the Git directory.
Git easy to use
Create a server code warehouse
sudo useradd git
sudo passwd git
sudo mkdir-p/var/git.server/project1
Cd/var/git.server
sudo chown git Project1
sudo chgrp git Project1
Establish ignore
CD Project1
$ cat >. Gitignore << End
> *. [OA]
> *.so
> *~
>!a.so
> Test
> tmp/
> End
sudo su git
sudo git--bare init
Client uses
Cloning a code base from a server
git clone [email protected]:/var/git.server/project1 Project1
git add a.txt//Add new file
git Add. Add new File
Git commit-am "New commit"//Commit version
git commit--amend-am "Rename New Commit"//resubmit, change comment
git checkout-b abeen//Create Abeen Branch
Git branch//View all branches
git checkout master//tangent back to master branch
git merge abeen//merge Abeen branch to master
Git pull Origin master//refresh the latest code from the server
Git push origin master//flushes the code to the server
git reset head^ & nbsp //revert to last commit status (head^, head~4, Commit-id, tag)
git status //view current track status
git log //View commit log
git log-3 //View the last three commit logs
git log-3--stat & nbsp;//displays simple statistics
git log-l-P & nbsp //Displays the details of the modification
Phased version
git tag v0.9//Create tag
git tag//Show All tags
git log v0.9//display submission status with tags
Git show--stat v0.9//tag to submit basic information
git RM filename//Delete the files in the code base
git checkout head^--filename//recovery file
git rm--cache filename//delete files only from code base, working directory files are not tracked status
git checkout head^--filename//Check out a previous version
git MV filename dirname//Move File
git show filename//View specific information for a submitted version
git diff head^ filename//Compare version differences
git reset-hard commit_id//Restore previous version
Remote Warehouse
git remote//view the current library
Git remote-v (verbose shorthand)//display the corresponding clone address
git remote add [shortname] [ULR]//Add repository
git fetch [remote-name]//Get remote Repository information
Git push origin master//push data to remote repository
git remote show [remote-name]//Display repository information
Git remote rename PB Paul//modify repository corresponding name
GIT remote RM Paul//Delete a repository
---------------------------------------------
Please refer to "Pro Git" for more information.