https://github.com/luhan420
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:
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), due to the four states of the file, There are three areas involved when using Git for project management:
(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 the GIT local repository:
①git Init: Initializes the current directory as a git local repository.
②git add: 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 in the current directory
③git Status: View the state of all files in the current Git repository and display them in red if tracking status.
④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: Submits the staging area.
Git commit-m < description information >
Git commit-a can skip the staging area and commit the tracked files to the staging file.
⑥git RM: Deletes a file from Git.
git rm--cached: 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 option expands to show differences in content per commit
git log--stat only shows a summary of the number of row increment statistics
git log--pretty=
, where option can be: oneline (to make each history message appear in a row), Short,full,fuller,format (output in the specified format)
GITK can open the visual viewing window of the history.
⑧git commit--amend: Modifies the last commit. The command is to submit a snapshot of the current cache and modify the last description.
⑨git Checkout--: Undo the modification of the file, use with caution!
⑩git Reset HEAD: 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.
-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 warehouses, the default is: Origin,master
Git push-u origin master//Submit a local project to the remote repository
GIT retrieves the remote repository github locally:
①git [url]: Under git switch to the directory where you want to store this item, run this command to clone the project to the current directory on the local disk
② Item retrieval local, remote repository github has updates, get updates
Git fetch origin//start getting updates
git merge origin/master//merge updates into local branch/master
Pair of people: Tenjuan
GitHub links and git Learning tips Summary