git notes and git server Setup

Source: Internet
Author: User

git installation


CentOS Installation

Yum Install-y epel-release

Yum install-y git


Tag:ubuntu apt-get Install git


git settings

In the user's home directory there is a. gitconfig file, which records the user's name and email address


git config--global user.name "name"

git config--global user.email "mail Address"


git commands

Git init makes this directory a git managed repository

Git add file adds files to the repository

Git commit-m "XXX" to be submitted after adding

Git status View status in current warehouse

git diff file vs. file changes

git log view all commit git repository records

git log--pretty=oneline line display

Git reset--hard xxxx can go back to the specified version

Git reflog can show all versions

Git checkout--XXX revert to last commit

git rm file is deleted in the Git repository


Create a remote Warehouse

    1. Sign up for a GitHub account

    2. git remote add origin [email protected]:rockycai/study.git

    3. Git push-u Origin Master


Cloning a remote repository

git clone [email protected]:rockycai/study.git


Branch Management

Git branch//view Branch

GIT branch Rockycai//Create Branch

git checkout rockycai//Switch to ROCKYCAI branch

git branch-d rockycai//Delete branch

Git branch-d rockycai


Onsite response

Git stash reserved Live

Git stash list view saved live

Git Stash Apply recovery site

git stash apply [email protected]{1}



Remote Branch

git remote-v Local New branch does not push to remote

git ls-remote orgin View Remote Branch

Git push Origin Branch-name

Git pull crawl Remote commit

git checkout-b branch-name origin/branch-name



Label Management

git tag v1.0 a tag for the master branch

git tag View all branches

git log--pretty=oneline--abbrev-commit//View history Commit

git tag v1.0 XXX tag for history commit

git tag v1.0-m "xxx" xxx

git tag-d v1.0 Delete tags

Git push Origin v1.0//push specified tag to remote

git push origin:refs/tags/v1.0 Delete remote tags


Alias:

git config--global alias.ci commit

git config--global--unset alias.br Delete Alias


Build a git server

1.yum install-y git

2. Add git users and set the shell to/usr/bin/git-shell, not allow users to log in normally, only use Git-shell

Useradd-s/usr/bin/git-shell git

Cd/home/git

3. Create a Authorized_keys file

mkdir. SSH

Touch. Ssh/authorized_keys

Chown-r git.git. SSH

chmod. Ssh/authorized_keys


Fix Storage Warehouse Directory

Mkdir/data/gitroot

Cd/data/gitroot

Git init--bare sample.git create a repository

Chown-r Git.git Sample.git


    1. Put the client segment public key in the GIT server/home/git/.ssh/authorized_keys file

    2. git clone [email protected]:/data/gitroot/sample.git


Tag

Git remote add Origin ssh://[email protected]/sample.git

Git push Origin rockycai:master//submit local ROCKYCAI branch as remote Master Branch

Git push Origin ROCKYCAI:ROCKYCAI//submit local ROCKYCAI branch as remote ROCKYCAI branch

git config--global alias.lg "log--color--graph--pretty=format: '%cred%h%creset-%c (yellow)%d%creset%s%cgreen (%CR)%c (bold blue) <%an>%creset '--abbrev-commit '

git notes and git server Setup

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.