Home > Development Tools > git > body text

Summary of Git related commands

藏色散人
Release: 2020-03-21 15:08:59
forward
3360 people have browsed it

Summary of Git related commands

Global settings

git config --global user.name "zyl"
git config --global user.email xxx@xxx.com
git config --list 检查你的git设置
git clone xxxxxx.git
Copy after login

Add new file

vim demo.txt
git add demo.txt 添加新的文件
git commit -m 'this is first commit' 提交到本地仓库,并且设置注释
git push 将推送这一转变为主分支
git rm xxx.txt 删除文件
git commit -m 'xxxx'; 提交到仓库
git push
git pull 拉取文件
git log -all 日志
git branch 查看所有分支
git log --stat xxx 查看 某个支点的提交信息
find .git/objects -type f 查看所有分支
Copy after login

Alibaba Cloud related Command:

Command line command

Git global settings

git config --global user.name "z1577121881"
git config --global user.email "1577121881@qq.com"
Copy after login

Create a new version library

git clone git@code.aliyun.com:z1577121881/tantou.git
cd tantou
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master
Copy after login

Existing folder or Git repository

cd existing_folder
git init
git remote add origin git@code.aliyun.com:z1577121881/tantou.git
git add .
git commit -am "你需要填写的一些信息"
git push -u origin master
Copy after login

Code cloud related commands

Set global information

git config --global user.name "你的名字"
git config --global user.email "你的Email"
clone 和push
git clone http://xxxx/xxxx.git
Copy after login

Create feature branch

git checkout -b $feature_name
Copy after login

Submit code

git commit -am "this is commit "
Copy after login

Push to the specified branch

git push origin $feature_name
Copy after login

For convenience, it is best to add the public key to git.

You can generate it through the following command

ssh-keygen -t rsa -C "xxxxx@xxxxx.com"# Creates a new ssh key using the provided email
# Generating public/private rsa key pair...
Copy after login

View the public key

cat ~/.ssh/id_rsa.pub
# ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC6eNtGpNGwstc....
Copy after login

After adding, enter

ssh -T git@git.oschina.net
Copy after login

in the Terminal to return Welcome to Git@OSC, yourname!

This article comes from the git tutorial column, welcome to learn!

The above is the detailed content of Summary of Git related commands. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
git
source:segmentfault.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template