Four Java Engineering--git Foundation

Source: Internet
Author: User
Tags diff git hooks

Git Learning reference: HTTPS://GIT-SCM.COM/BOOK/ZH/V2

Common commands
  • git initInitialize Project
  • git add *.javaAdd files to git version control (all files for. java suffix)

    There are three states of Git, commited (committed), modified (modified), staged (staged), and submitted representations of data that have been safely saved in the local database. Modified to indicate that the file was modified but not yet saved to the database. Staged indicates that the current version of a modified file has been marked for inclusion in the next commit snapshot.
    This introduces the concept of three working areas of a git project: Git repositories, working directories, and staging areas.
  • git status -sThe current state, generally have the next step of the prompt information -s output concise information
  • git commint -m ‘提交描述信息‘Submit to local Warehouse
  • git clone https://github.com/xuelingxiao/java-knowledge-structure knstuctCloning a remote repository and renaming

      > GitHub 有一个十分详细的针对数十种项目及语言的 .gitignore 文件列表,你可以在 https://github.com/github/gitignore 找到它.
  • git diffSee which changes have not yet been staged, and see which changes are staged for the next commit;
  • git diff --cacheView Staging Area
  • git commit -aSkipping add, staging the trace files and committing them together
  • git rm filename.txtTo remove a file from tracking status
  • git rm --cached filenameRemove files from staging area, keep workspace files
  • git mv filefrom filetoMoving files
  • git logView commit History
  • git log -p -2-P shows the difference in content per commit, 2 shows the last two commits, commonly used git log --graph ,, git log --pretty=oneline[short,full,fuller,format] and git log -Sfunctionname git log --grep 关键字 others see Help
  • git commit --amendAmend will be used to fix the last commit, such as the last commit if you forget some files, you can use this command to repair, GIT will amend file with the previous file as a single commit
  • git reset HEAD 文件名.txtCancel Staging
  • git checkout -- 文件名It is dangerous to undo changes to the file, because local modifications may be overwritten by files from the far end
  • git remote -vView remote Repository information for configuration,-V shows the shorthand and URL saved by git
  • git remote add knstuct https://github.com/https://github.com/xuelingxiao/java-knowledge-structureAdd Remote Warehouse Configuration
  • git fetch knstuctGet the repository, that is, the mirror is synchronized to the local
  • git pull knstuctPull the remote branch to local and merge, Fetch does not merge
  • git push -f remote-name branch-namePush to remote,-F rolls back version (Force push)
  • git remote show originView more information on a remote branch
  • git remote rename oldname newnameRemote Branch Rename
  • git remote rm branch-nameTo remove a remote branch
  • git tagList labels
  • git tag -l ‘v1.8.5*‘List only labels for the v1.8.5 series
  • git tag -a v1.1 -m ‘v1.1版本的标签‘Create a note tag (git tags are divided into two categories: lightweight and sticky notes, note tags that store a complete object in a git database, and can be checked to include tagged people)
  • git tag v1.2 -lwPlay Light weight Labels
  • git push origin v1.1Push tags to the remote so you can share tags
  • git checkout -b brahchname tagnameCheck out the label, actually check out the label version to the workspace-B just for the first time checkout use
  • Alias settings, see example below
$ git config --global alias.co checkout$ git config --global alias.br branch$ git config --global alias.ci commit$ git config --global alias.st status$ git config --global alias.unstage ‘reset HEAD --‘--上面命令运行后,下面两条语句等价$ git unstage fileA$ git reset HEAD -- fileA--如果是外部命令, 可以在命令前加!$ git config --global alias.visual ‘!gitk‘
    • git merge branch masterMerging branches
    • git rebase masterYou have to use less if you can't control it.
Git-flow

How the planning team uses Git, a set of specifications that uses git; You can refer to Google's gitflow.

git hooks

Can be used in CI, automatically released, integrated with Jenkins.

Through this study, we can basically deal with the needs of the ordinary. As part of engineering, Git learns so much (and then, if you have time later, to sort out more about Git), the next step is to learn Jenkins.

Four Java Engineering--git Foundation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.