Git Learning Notes

Source: Internet
Author: User
Tags gpg using git git clone repository


simple use of GitHubgit config--global user.name "qiu" git config--global user.email "[email protected]" Initialize git init add file git. Commit git commit-m ' submit instructions ' generate SSH key Ssh-keygen will be generated in ~/.ssh/directory, Id_rsa private key, id_rsa.pub public keygithub-->settings--> Ssh-keys Add key (Enter the public key id_rsa.pub in key) Connect to GitHub ssh-t [email protected] Push the local git repository to GitHub git remote add origin [email protected]: username/project. Git Git push Origin master
========================================
Some information settings for gitgit config--global user.name "xx" git config--global user.email "[email protected]" git config--global colo R.ui Auto color settings git config--global alias.co checkout alias settings, in this example set the checkout bit COgit config--global core.quotepath off windows using git bash with non- ASCII the file name of the character is displayed as "\346\226\260\350\246 ..." . If you set the following, you can let the non- ASCII the file name of the character is displayed correctly. Alias:
 aliasalias alias
Alias' Reset HEAD '
Alias"Log--color--graph--pretty=format: '%cred%h%creset-%c (yellow)%d%creset%s%cgreen (%CR)%c ( Bold blue) <%an>%creset '--abbrev-commit '
--global is not referring to the current user, does not refer to the current warehouse function
The warehouse configuration file placed in the. Git/config user profile is placed in the. Gitconfig of the user's home directory and can be modified in the configuration file
git init initialization will appear. Git directory the. Git directory is the Repository (repository), the current project directory workspace (working directory)Git add file actually adds files to staging area (index or stage) git commit-m "" to commit all staging area contents to the current branch git Status View state git diff <file> can view not been Add, modify those contents

git version fallbackgit log--pretty=oneline single line view that commit_id, can add--graph git reset--hard head^ HEAD means the current version head^ represents the previous version head^^ represents the last version head~ 100 on 100 versions git reset--hard commit_id git reflog View history command (last insurance) git checkout-file undo Workspace modified or deleted if added to staging area, advanced git R ESET HEAD file, and then in the previous step

Remote WarehouseSsh-keygen-t rsa-c "[Email protected]"
git remote add origin [email protected]:qiuhoude/xxx.git remote Repository Name is origin, can also be other git remote view remote library git remote-v more Detailed git remote remove <repository_name> delete remote repository Git push-u origin master-u Rep UpdateThe first time we pushedMasterBranch, add a-Uparameter, Git will not only take the localMasterbranch content pushes the remote newMasterBranch, it will also bring the localMasterBranch and RemoteMasterbranches to simplify commands at a later push or pull Future push commands can be used git push Origin masterGit pull crawl git branch--set--upstream dev origin/dev and Remote repository branch build link git checkout-b dev origin/dev Create local branch and remote divide SupportVerify that you are connectedSsh-t-O "Verifyhostkeydns yes"[email protected](Just on GitHub)git clone xxx.git clone repository to local, support HTTPS and SSH protocol, but SSH support native git protocol fastest

Branch ManagementGIT encourages extensive use of branchinggit branch <name> create branch BranchGit checkout-b <name> Create and switch branches git branch view branch git checkout <name> switch branch git merge <name> merge A branch to the current branch to git branch-d <name> Delete branch git branch-d <name> Force Delete Branch Branch management policy: Git uses the Fast forward mode by default when merging branches, which Mode discards branch information after deleting a branch, so use--no--ff git merge--no--ff-m ' <commit_message> ' <branch_name> when merging branches
Branching policy :

First of all, themaster branch should be very stable, that is, only to release the new version, usually do not work on it;

So where do you work? Work on the Dev Branch, that is, thedev branch is unstable, at some point, such as the 1.0 release, then merge the Dev branch to Master , in the master Branch Release version 1.0;

You and your little friends each work on the Dev Branch, and everyone has their own branch, and it's time to merge on the Dev branch.

So, the branch of teamwork looks like this:


Bug Branch: git stash can store the current state, if the new file needs to be add to staging area to stash git stash list view current status lists git stash apply [email protected]{0} replies to the specified state, but does not delete stash content git stash drop Delete stash content git stash pop reply and delete stash

When fixing a bug, we will fix it by creating a new bug branch, then merging and finally deleting;

when the work on hand is not finished, first put the work site git stash And then go fix the bug, fix it , and then git stash pop , back to the job site.

After modifying the master branch bug, to update to the current branch, you can merge the Master branch into the yourselves branch, resolve the conflict first and then merge the Dev branch to master


Label Management when we publish a version, we usually start with a tag in the repository, so that it's the only version that determines the time of the tag. Any time in the future, the version of a tag is taken out of the historical version of that tag. Therefore, the tag is also a snapshot of the repository. git's tag is a snapshot of the repository, but it's actually a pointer to a commit (much like a branch, right?). However, the branch can be moved and the label cannot be moved, so creating and deleting tags is instantaneous.
Git Tag v1.0 creates a performance, the default tag is hit on the latest commit on git tag <tag_name> commit_id if you want to hit the previous commit, you can add commit_id git tag-a <tag_name>-M ' <tag_message> ' commit_id Add Annotated label,-a specify tag name,-m Specify description text git tag-s <tag_name>-M ' <tag_ Message> ' commit_id-S represents the private key label, signed with PGP signature, therefore, must first install GPG (GnuPG), if not found GPG, or no GPG key pair, will be error
git tag to view a list of tags, plus-n display tag annotations git show <tag_name> view tag contents
git tag-d <tag_name> Delete tags, if you want to delete the Remote warehouse label, first delete the local label, and then Git push origin:refs/tags/<tag_name>
git push origin <tag_name> push tag to remote repositoryGit push origin--tags push so tag to remote repository
git's Ignore fileCreate the. gitignore file under the project root and submit it to git, so the Ignore file Https://github.com/github/gitignore

Create a git server1 Install git sudo apt-get install git 2 add git user to run git sudo adduser git 3 create certificate, first switch to git user under Su git--and Ssh-keygen -T ras-c ' <email_adress> ' to create a/home/git/.ssh/authorize_key file and join the public key that needs to be logged in one line. 4 initialize git repository sudo git init--bare/srv/<repository>.git (git repository is usually. Git end) 5 Modify the repository owner sudo chown-r git:git/ Srv/<repository>.git 6 Disable shell login found in/etc/passwd
git: x: 1001 : 1001 :,,,:/home/git:/bin/bash
Change into
git: x: 1001 : 1001 :,,,:/home/git:/usr/bin/git-shell
Advanced public Key Management can use Gitosis https://github.com/res0nat0r/gitosis advanced Rights Management Gitolite Https://github.com/sitaramc/gitolite





Git Learning Notes

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.