Git's experience
Git is a distributed management tool, through the fingerprint string to maintain the integrity of the data at all times, concerned about the overall change of the file data, do not save the variance before and after the change data; Git saves a historical update of the project on the local disk, and all the most operations only need to access local The internet is not required. Of course, you can use Githbub to host code, remote development, to facilitate the team to compare the situation (which is the advantages of git distributed); the developer simply clones the project locally, develops it accordingly, and then uploads the push to GitHub (GitHub uses UTF-8 encoding, so if the uploaded file is not encoded in utf-8, it may be garbled) for other developers to update. Simple beginner Use reference: http://blog.csdn.net/u011384252/article/details/9351549
Any file in the GIT library has four states: No tracking status untracked, tracking status tracked (unmodified state unmodified, modified state modified, staging status staged), reference http://blog.csdn.net/ u011384252/article/details/9406503, because of the above four states of the file, there are three areas involved in project management using git:
(1) Git Local Data directory: Each project has a git directory, which is where Git stores metadata and object databases. This directory is very important, each time you clone a mirrored warehouse, the actual copy is the data in this directory.
(2) Working directory (Project Workspace): Take out a version of all files and directories from the project, to start the follow-up work is called the working directory, that is, our project development directory.
(3) Staging area: The so-called staging area is just a simple file that is typically placed in a git directory.
basic usage of git local repository: &NBSP;①GIT Init: Initial the current directory as a git local repository. ②git Add <filename>: If a file is not tracked, add a file to Git version control, let git track it, and if a file is modified, place a file in staging area. git add . : "." Point represents all content under the current directory ③git status: View the status of all files in the current Git repository, and display them in red if they are in the tracking state. ④git diff: Compare the differences between the current file in the working directory and the snapshot of the staging area, that is, changes that have not been staged since the modification. ⑤git Commit: Submit a staging area. git Commit-m < description information > git Commit-a can skip the staging area and submit the tracked files in a staged file. ⑥git RM <filename>: Deletes a file from Git. git rm--cached <filenmae>: Deletes a file from staging area, but remains in the working directory. That is, the file becomes not tracked. ⑦git log: View the project submission history. git log-p options Expand Show content differences for each submission git Log --stat Show only a brief count of incremental row counts &NBSP;&NBSP;&NBSP;&N Bsp; git log--pretty=<option>, where option can be: oneline (to make each history message appear in a row) , Short,full,fuller,format (output in specified format) &NBSP;GITK can open the visual viewing window of the history. ⑧ git Commit--amend: Modify the last commit. The command is to submit a snapshot of the current cache and modify the last description. ⑨git Checkout-<filename>: Undo the changes to the file, use with caution! ⑩ git Reset HEAD <filename>: revokes the staging of the file, returning the file to its pre-staged state.
basic usage of git remote repository: ①git clone [url]: Clone a remote repository locally. ②git Remote: View the currently configured remotes, after cloning a project, at least one remote repository named origin, which git uses by default to identify the original repository you cloned. such as Git remote add origin[email protected]: usernmae/repositoryname.git-v: Displays the corresponding clone address. git remote add [remote-name] [url]: Add a new remote repository. git remote show [remote-name]: View remote repository information. Git remote RM [Remote-name]: Remove the repository. git remote rename [old-remote-name] [new-remote-name]: Renaming the repository. ③git push [Remote-name] [branch-name]: Push data to the remote repository, remote-name refers to the remote warehouse abbreviation, branch-name refers to the branch name. For cloned repositories, the default is: Origin,master Git push-u Origin master//submit local project to remote repository
git retrieves the remote repository github locally: ①git [url]: switch to the directory where you want to store this item under GIT, run this command to clone the project to the current directory on the local Disk ② project fetch locally, update on GitHub on remote repository, get update git fetch or Igin//Start get update git merge origin/master//merge updates into local branch/master
Git learning Experience