Many people think Git is too confusing or complex version control system. This article is for some people who want to use Git quickly,
For most basic requirements, this article covers 70% to 90% of the use
Before using Git, you need to establish a repository. You can use an existing directory as a Git repository or create an empty directory
Using your current directory as the Git repository, we just need to initialize it
Use our specified directory as Git repository
From now on, we will assume that you are in the root directory of Git warehouse, unless otherwise specified
Add New File
We have a warehouse but nothing. You can use the add command to add files
You can use add... to continue adding task files
Now that we have added these files, we hope they can really be saved in the Git repository,
To do this, we submit them to the warehouse
git commit -m "Adding files"
If you don't use - m, an editor will appear to let you write your own comments
When we modify many files, instead of adding every one, we can use the - a flag to automatically commit local changes
git commit -a -m "Changed some files"
The - a option of the git commit command can only</span> Documents that have been modified or deleted and have been managed by git Submit to the warehouse.
Please note that - a will not cause new files to be submitted, but can only be modified.
First, we clone a library from the server and upload it
git clone ssh://example.com/ ~/www/project.git
Now we can push it to the server after modification
git push ssh://example.com/ ~/www/project.git
If you have pushed as above, the following command indicates that the current branch is automatically merged with the only tracking branch.
Update from non default location to the specified url
git pull http://git.example.com/project.git
More than five minutes?
How do you want to delete files from the repository? We use rm
Branch and Merge
Branching is completed locally and is fast. To create a new branch, we use the branch command.
The branch command will not take us to branches, just create one. So we use the checkout command to change the branch.
The first branch, or main branch, is called "master".
While your branch can be submitted, it will not reflect changes in the main branch. When you do or want to submit changes to the main branch, switch back to the master branch and use merge.
git checkout master git merge test
If you want to delete a branch, we use the - d flag