常用git 命令

xiaoxiao2021-02-28  61

设置用户名密码:

git config --global user.name [username] git config --global user.email [email]

修改远程仓库地址

git remote rm origin 

git remote add origin url

克隆代码

git clone url

提交代码三步

1.add 提交本地代码

git add 文件名

如果add 全部则git add .

2.commit 提交代码到本地仓库

git commit -m"注明修改"

3.push 提交代码到远程仓库

git push origin 提交分支

查看分支

git branch

commit 后回退

1.保留本地代码

git reset --mixed commit_id

2.不保留本地代码,

git reset --hard commit_id

将本地代码全部回退

git reset --hard

push后的代码回退

git revert commit_id

查看commit_id

git log

回退的代码不止一次提交记录的话先revert最近的提交记录,依次回退

查看代码文件的变化

git status

查看代码内容的变化

git diff

转载请注明原文地址: https://www.6miu.com/read-75595.html

最新回复(0)