git生产常用命令

1. 从master分支copy代码,修改后push到自己分支

下面解决修改代码后push,报错你的代码版本过久的问题

Git copy XXX

修改你的代码后

Git checkout -b new_branch

Git add .

Git commit -m “xxx”

//下面更新你的代码,会让你的所有代码变回master原样,但是你修改的代码已经在暂存区,push就可以了

Git pull origin master

Git push origin new_branch

2. 设置name和email

Git --global user.name “XXX”

Git --global user.email “xxx”

为啥修改了name和global name,上传后还是显示别人的名字:

必须要email和name都对应修改才行

3. Push后回退commit

回退一个

Git reset --soft HEAD~1

回退到master最新版本

Git reset --soft origin/master

然后

Git add .

Git commit -m “xxx”

Git push --force-with-lease origin new_branch

你可能感兴趣的:(git)