Content from: https://www.liaoxuefeng.com/wiki/896043488029600/896067074338496
1.Linux install Git
First, you can try to enter git
and see the system has not been installed Git:
$ git The program 'git' is currently not installed. You can install it by typing: sudo apt-get install git
Like the above command, there are many Linux friendly and will tell you Git is not installed, will tell you how to install Git.
If you happen to use Debian or Ubuntu Linux, through a sudo apt-get install git
will can be done directly Git installation is very simple.
Little old Debian or Ubuntu Linux, the command should be changed sudo apt-get install git-core
, because in the past there is a software called GIT (GNU Interactive Tools), Git result can only be called git-core
up. Because Git fame is too great, then put into GNU Interactive Tools gnuit
, git-core
officially changed git
.
2.windows install Git
Git directly from the official website to download the installer , after the installation is complete, find the "Git" in the Start menu -> "Git Bash", jumped out a window similar to the command-line stuff, it shows Git installed successfully!
After installation, you need to set the final step, at the command line:
$ git config --global user.name "Your Name" $ git config --global user.email "[email protected]"
Note that git config
the command --global
parameter, use this parameter, all Git repository that you will use this configuration on this machine, of course, you can specify a different user name and Email address of a warehouse.
3. Create Repository
Warehouse repository, also known as the English name repository
$ Mkdir learngit // Create a directory
$ cd learngit // into the directory created inside the
$ pwd // command is used to display the current directory
/ Users / michael / learngit
The second step, through the git init
command to manage this directory can become a Git repository:
$ git init Initialized empty Git repository in /Users/michael/learngit/.git/
Initialize a Git repository, use the git init
command.
Add files to the Git repository, in two steps:
- Using the command
git add <file>
, pay attention, it can be used repeatedly to add multiple files; - Use the command
git commit -m <message>
to complete.