First contact with git, in order to remember deeply, the simple process of learning to record down.
This article documents the installation, configuration, and process of creating a repository and adding files to a repository on Ubuntu.
1, git installation: (ubuntu-linux very friendly installation tips)
[Email protected] 3385-mt:~git //See if Git installer "git" is not installed. You can install it using the following command:sudoinstall git[email protected]-hp-pro-3385-mt:~$
sudo apt-get install
git [sudo for Ubuntu: Reading Package list ... Completing the dependency tree for the package being analyzed
2. Configure Email and username
" [email protected] " the "Your name"--global parameter, all the warehouses on this machine, will use this mailbox and user name (or different ID of the repository).
3. Create a version library
// better find a suitable place to build an empty directory [Email protected] 3385-mt:~$
mkdir
Joe [Email protected] -hp-pro-3385-mt:~$ cd joe/[email protected]-hp-pro-3385mkdir learngit [email protected]-hp-pro-3385pwd/home/ubuntu/joe[email protected]- hp-pro-3385
CD learngit/
// the initialization of Git [Email protected] 3385-mt:~/joe/git init/home/ubuntu/joe/learngit/.git/// Discover last more. Git's hidden directory, which is the warehouse LS- A can view this directory
4. Add files to Repository
// in the. git sibling directory, which is the Learngit directory, create the file and write Touch vi readme.txt// file Add to Repository and submit [email protected]3385
git add readme.txt
// The Philosophy of Unix is that "no news is good news," stating that adding success. [email protected]3385
git commit-m "Joe ' s first txt"//
-M Add meaningful notes [Master (root submission) B401FAF] Joe's firsttxt1file2 insertions (+) // changed a file, inserted 2 lines of information 100644 readme.txt//Commit can submit multiple files at once, So you can add multiple files at once as follows:"add 3 files. "
5. Add the modified file again
//the contents of the modified text are as followsGit is a distributed version control system. Git is Freesoftware.//git Status View the current state of the warehouse[Email protected]:/home/ubuntu/joe/learngit# git status is in a change that branch master has not yet staged for submission: (Using"git add <file>, ... ."update the content to be submitted) (using"git checkout--<file>, ... ."Discard workspace changes) Modified: Readme.txt Modification has not yet joined the commit (using"git add"and/or"git commit-a")//git diff to see what's changed[Email protected]:/home/ubuntu/joe/learngit#
git diff
Readme.txt diff--git A/readme.txt b/Readme.txtindex F7249b8. 2FDF0C4100644---A/Readme.txt+ + + breadme.txt@@-1,2+1,2 @@-Git is a version control system+git is a distributed version control system git is FreeSoftware//then add and submit the modified file to the warehouse[Email protected]:/home/ubuntu/joe/learngit# git add readme.txt [email protected]:/home/ubuntu/joe/learngit# git status is at the branch master to commit the change: (Using"git reset HEAD <file>"withdrawal staging Area) Modified: Readme.txt//Check Status again after submission (observe)[Email protected]:~/joe/learngit$
git commit-m "Add distributed"
1 file 1 1 deletion (-) [email protected]:~/joe/learngit$ git status in branch Master no file to submit, clean workspace
Git learning Notes (1)--Install, configure, create libraries, add files to libraries