git 免密

cd ~cat ~/.ssh/id_rsa.pubcat ~/.ssh/id_rsa.pub

配置信息

# 不加global选项意味仅当前项目使用如下配置
git config --global user.name "John Doe"
git config --global user.email johndoe@example.com
git config --global user.password 1234 #慎用

添加已有文件夹到git仓库

cd ucd
git init
git remote add origin git@10.1.7.15:ucd/ucd.git
git add .
git commit -m "first commit"
git push -u origin master

git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/motenzhang/condenast.git
git push -u origin master

更新github上fork别人的代码

# 1.克隆自己的到本地
git clone https://github.com/motenzhang/moodle.git
# 2.添加源/上游地址 upstream即别人代码的git地址
git remote add upstream https://github.com/moodle/moodle.git
# 3.拉取源地址到本地
git fetch upstream
# 4.获取master代码并与源代码合并
git checkout master
git merge upstream/master
# 5.推送master代码到自己github仓库
git push origin master
# 11.第二种方法 删除之前fork的代码 重新fork

git完整迁移(包含代码 提交 分支等所有文件)

mkdir temp_dir
cd temp_dir
git clone --bare git@10.1.7.15:old/old.git
cd old.git
git remote set-url --push origin https://github.com/motenzhang/new.git
git push --mirror
cd ..
# 删除本地
rm -rf project_name.git