Git使用笔记

1 临时修复一个问题

切换分支到master

git checkout master

基于master分支创建分支

git branch fix_20201027

开发测试完成以后

git add .  && git commit -m 'fix 20201027 error'

开发测试完毕后切换到master分支

git checkout master  

合并在新分支的更改

git merge fix_20201027

推送到远程 

git push origin

删除本地分支 

git branch -d fix_20201027

2 增加一个分支长期开发并线上同步一个

git checkout master - 切换到master分支

git branch new_branch_name  --创建本地新分支

git push origin develop:develop --将本地分支(可以是新创建的)推送到员工develop分支(远程服务器没有会自动创建)

git checkout new_branch_name  切换到新的分支

git push --set-upstream origin new_branch_name  -- 设置本地当前分支跟踪远程new_branch_name

git push origin --delete new_branch_name   -- 删除远程分支

Git远程推送时记住用户名和密码

 a 推送时候带上账户密码

git remote set-url origin http://yourname:password@bitbucket.org/yourname/project.git

b 本仓库内设置账户密码文件

touch .git-credentials

内容为:

https://yourname:password@github.com

c 设置全局账户密码

# git config命令

# 1.查看git配置信息
$ git config --list
# 2.查看git用户名、密码、邮箱的配置
$ git config user.name
$ git config user.password
$ git config user.email
# 3.设置git用户名、密码、邮箱的配置
$ git config user.name "hhh"
$ git config user.password "123abc"
$ git config user.email "123@qq.com"
# 3.设置git用户名、密码、邮箱的配置(全局配置)
$ git config --global user.name 用户命
$ git config --global user.name hhh
$ git config --global user.password 密码
$ git config --global user.password 123abc
$ git config --global user.password 邮箱
$ git config --global user.email "123@qq.com"
 

Git在windows的账户密码

控制面板用户帐户凭据管理器

远端的账户密码更改以后,本地需要更改用户凭据

参考博客:

https://blog.csdn.net/qq_34802511/article/details/90055273

https://www.jianshu.com/p/7182b2faab84

原文地址:https://www.cnblogs.com/xuweiqiang/p/13517654.html