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
Sign up for a GitHub account
git remote add origin [email protected]:rockycai/study.git
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
Put the client segment public key in the GIT server/home/git/.ssh/authorized_keys file
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