android--最常用的git命令,将项目推到github或码云等,回退代码

1.本地项目上传到码云或是github等网站
git init
git add .
git commit -m “first commit” (first commit 本次提交的内容)
git remote add origin https://github.com/xxxx/xxx.git
git push -u origin master (这一句执行的时候 可能需要输入你的 git 账号 和密码)

如果在最后一行命令中显示push失败,那么就强行推送,覆盖码云或是github上的readme等自动创建的文件。
git push -f https://github.com/xxxx/xxx.git master

2.如果push代码错误的时候,想用命令行回退到某个位置,那么就用下面的代码
git reset –hard c2522b08a 进行本地还原
git push -f https://github.com/xxxx/xxx.git master 强制push到远程仓库
这里写图片描述

猜你喜欢

转载自blog.csdn.net/yuezheyue123/article/details/81911039