跳转到主要内容

git使用指南

# Git global setup
git config --global user.name "你的名字"
git config --global user.email "your email"



# Create a new repository
git clone http://10.0.0.43:10080/tjxt/htc-dashboard.git
cd htc-dashboard
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master


# Existing folder
cd existing_folder
git init
git remote add origin http://10.0.0.43:10080/tjxt/htc-dashboard.git
git add .
git commit -m "Initial commit"
git push -u origin master


# Existing Git repository
cd existing_repo
git remote rename origin old-origin
git remote add origin http://10.0.0.43:10080/tjxt/htc-dashboard.git
git push -u origin --all
git push -u origin --tags



# 增加文件
git add .


# 提交更改
git commit -m [comment]

# 推送到远程
git push origin loacl:remote

# 获取
git pull origin branch-name


# 修改文件
git status

# 删除文件
git rm

# 移动文件
git mv

# 列出本地分之
git branch

# 列出远程分之
git branch -r

# 列出所有分之
git branch -a

# 新建分支
git branch [branch-name]

# 切换分之
git checkout [branch-name]

# 从指定分之合并
git merge [branch-name]

# 删除分之
git branch -d [branch-name]

# 删除远程分之
git push origin --delete branch-name

# 递归获取
git fetch [remote]