Git is introduced

Distributed: Git version control system is a distributed system, is used to save the project source code history of the command line tool;

Git savepoints: Git savepoints can track files in the source code and get the status of the entire project at a point in time; Multiple source submissions can be merged at this savepoint or retreated to a single savepoint.

Git offline :Git can commit code offline, so it is completely distributed. This means that Git is much faster than tools like SVN, which need to be online and can be very slow to submit code if the network is bad.

Git is snapshot-based: older version control tools like SVN save commit points as patch files. Git commit points to a snapshot of the project at the time of commit, which contains some metadata (author, date, GPG, etc.).

Git branch and merge: The branch model is the most significant feature of Git, because it changes the development mode of developers, version control tools such as SVN put each branch in a different directory, Git can switch different branches in the same directory; Immediateness of branches: Branches are created and switched almost at the same time. Users can upload some branches and hide others locally, without having to upload all branches to GitHub. Branch flexibility: users can create merge and delete branches at any time, and multiple people can realize different functions. Multiple branches can be created for development, and then branches can be merged. This way makes development fast, simple and safe.

Download Git

Download git OSX :git-scm.com/download/ma… Download Git for Windows :git-scm.com/download/wi… Download Git for Linux :git-scm.com/download/li…

Install Git

Sudoyuminstallgit sudoyuminstallgit sudoyuminstallgit sudo apt-get installgit If not, the installation method will be prompted.

Git Workflow

A brief introduction to some uses of Git

.gitignore file masking files:.gitignore files tell Git which directories or files to ignore and will not be committed. Common scenarios: After writing code, mutation debugging and other operations will be performed. The.gitignore file will be used to shield these compiled files, which do not need Git tools to manage. Android. Gitignore: The bin and gen directories can be ignored on Android. .gitignore location: project root directory;

Filter mode: there are two modes in.gitignore in Git, open mode and conservative mode. Conservative mode has a higher priority than open mode.

Open mode: sets which files live directories are filtered. All files or directories listed in files are filtered out. — Filter directory: /bin/ filters the bin directory. All directories and files under this directory are not submitted. *.zip *. Class filters files with the suffix zip and class. These files will not be submitted. — Filter specified file: /gen/ r.java, filter the file, the file is not submitted;

Conservative mode: Set which files are not filtered, and all files listed in the file must be submitted completely. — Trace directory:! / SRC, all files in this directory will be committed; — Trace a certain type of file:! *.java, all Java files should be preserved; — Trace specified file:! / androidmanifest.xml, this file needs to be retained and submitted;

Configuration principle: in general, open mode is used together with fish conservative mode; Eg: There are many directories and files in a directory. If only one file needs to be saved, use the open mode to save the file, and use the conservative mode to save the file. The conservative mode has a higher priority than the open mode.

Git command quick lookup table

Git configuration

git config --global user.name "robbin" git config --global user.email "[email protected]" git config --global color.ui true git config --global alias.co checkout git config --global alias.ci commit git config --global alias.st status git Config --global alias.br branch git config --global core.editor "mate -w" # Git configuration file ~/. Gitconfig Git configuration file Git show $id git co -- <file Git add. Git rm <file> # Delete files from the repository git rm <file> --cached # Git reset <file> # restore the working file from the staging area. Git reset --hard # restore the last committed state. Git ci <file> git ci. Git ci-am "some comments" git ci --amend # git revert <$ID > Git diff git diff <$id1> <$id2> Git diff <branch1>.. <branch2> # Compare staged Git diff --cached git diff --stat # Only compare statistics to view commit records Git log -p git log -p git log -p git log -p On Mac, you can use tig instead of diff and log. Git br <new_branch> # create a new branch Git br Git co -b <new_branch> # git co -b <new_branch Git co -b <new_branch> <branch> Git co $id -b <new_branch> Git br -d <branch> git br -d <branch Git merge origin/master --no-ff # Git rebase <branch> Git co <branch> &&git rebase master &&git co master &&git co <branch> Git diff >.. Git apply... Git apply --check... / stash stash list/stash stash apply/stash stash drop/stash drop Git pull --no-ff # Git pull --no-ff # Git pull Git co --track origin/branch # Git co-b <local_branch> origin/<remote_branch> Git push -u origin master git push -u origin master git push -u origin master Git push origin <local_branch> Git push origin :<remote_branch - d < branch >), Git remote add origin Git remote add origin Git remote add origin git@github:robbin/robbin_site.git # add git remote set-url origin [email protected]:robbin/robbin_site.git # Git clone --bare robbin_site robbin_site.git # Git &&cd robbin_site.git &&git: run the following command to create a pure repository: SCP -r my_project.git [email protected]:~ # Git remote add origin [email protected]:robbin/robbin_site Git push -u origin develop # commit local develop branch to remote develop branch for the first time Git branch --set-upstream master (" upstream master ") git branch --set-upstream master origin/master git branch --set-upstream develop origin/developCopy the code

Git mind maps

Some pictures from the network, if there is infringement, please inform!Copy the code

Thanks for your support, please follow daimajiqiao to comment 18 to get a git mind map

Learning materials

GitX (L) (OSX, Open Source) : gitx.laullon.com/ Tower (OSX) : www.git-tower.com/ Source Tree (OSX, free) : www.sourcetreeapp.com/, making for Mac OSX, free) : mac.github.com/ GitBox (OSX) : itunes.apple.com/gb/app/gitb… Git Community Reference Book: book.git-scm.com/ Professional Git: progit.org/book/ such as Git thinking: think-like-a-git.net/ GitHub Help: Help.github.com/ graphical guide to Git a: marklodato.github.com/visual-git-… Git tutorial: www.liaoxuefeng.com/wiki/001373…

You can get git learning materials and git high definition commonly used naming atlas