Git 全局设置
git config --global user.name "***"
git config --global user.email "***@qq.com"
创建 git 仓库
mkdir code_dir
cd code_dir
git init
touch README.md
git add README.md
git commit -m "first commit"
git remote add origin https://gitee.com/****.git
git push -u origin "master"
已有仓库
cd existing_git_repo
git remote add origin https://gitee.com/*****.git
git push -u origin "master"
一套代码多个github 共享
- 进入.git 文件夹,打开config文件,内容如下:
[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
symlinks = false
ignorecase = true
[remote "origin"]
url = https://gitee.com/****.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
- 修改后
[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
symlinks = false
ignorecase = true
[remote "origin"]
url = https://gitee.com/****.git
fetch = +refs/heads/*:refs/remotes/origin/*
[remote "mirror"]
url = https://github.com/*.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
- 上传到github
git push mirror master
常用命令
git status
git log
git pull
git push origin master
git reset --soft commit-id
git reset --hard commit-id