git 切换用户、新的远程仓库地址

origin:远程的意思,origin master:是远程master分支,不加origin:是本地分支

# 下载远程仓库到本地

git clone 远程仓库地址

# 若下载项目报错 : fatal: unable to access 'https://github.com/jeecgboot/jeecg-boot.git/': OpenSSL SSL_read: Connection was reset, errno 10054,意思是证书过期了。其实就是SSL卡住了你,因此最快的解决方法就是关掉SSL验证。

git config --global http.sslVerify false

fatal: unable to access 'https://github.com/XXX/XXX.git/': Failed to connect to github.com port 443 after 21129 ms: Timed out,这个超时了无非就是你的代理出了点问题,不过好在git上用几个命令就能够很快搞定。

git config --global --unset http.proxy

git config --global --unset https.proxy

# 查看用户名

git config user.name

# 查看用户邮箱

git config user.email

# 修改用户名和邮箱的命令

git config --global user.name "Your_username"
git config --global user.email "Your_email"

# 移除旧的关联的git仓库地址

git remote rm origin

# 关联新的git远程仓库地址

git remote add origin 新的远程git仓库的地址

# 查看是否关联到了新的git仓库地址

git remote -v

# 查看所有分支

git branch -a

# 检出远程分支(origin/release)到本地分支(release)

git checkout -b release origin/release

# 合并本地分支(release):先检出要合并的目标分支上,再merge来源分支

--allow-unrelated-histories(合并提交历史记录,因为两个分支仓库地址不一样,提交历史记录也不一样,所以要用此命令合并)
git merge release
git merge release --allow-unrelated-histories

 # 将当前目录下的所有文件(包括编译文件)添加到版本库

git add .

# 添加待提交文件和提交注释

git commit -m "first commit"

# 拉取(合并)远程仓库文件到本地(不加origin master就是当前分支)

git pull
git pull origin master

# 上传(推送)本地文件推到远程仓库(不加origin master就是当前分支)

git push
git push origin master

# pull、merge 报错 : fatal: refusing to merge unrelated histories,原因:远程repository和本地的repository提交历史不一致

git pull --rebase 加上--rebase参数的原因是,在多人开发中,有多个merge commit,如果不加该参数,则有多个历史提交线,而它的作用,就相当于把分叉的提交线中的一条,每一次提交都捡选出来, 在另一条提交线上提交。最后也形成一条单一的提交线。

git pull --rebase origin master
 简单来说就是:以远程提交为主,更新并合并,git pull = git fetch + git meger

# 滚回上一次提交记录(慎重)

git reset --hard HEAD^
posted on 2022-01-11 18:05  尹镇镇  阅读(782)  评论(0)    收藏  举报