首页 > 其他 > 详细

Git常用命令-02

时间:2021-04-20 13:45:33      阅读:24      评论:0      收藏:0      [点我收藏+]

设置用户信息
git config --global user.name “itcast”
git config --global user.email “hello@itcast.cn”

查看配置信息
git config --list

初始化gi仓库
git init

添加到缓存区
git add a.txt 提加当前文件或文件夹 git add . 提交当前所有文件

日志信息
git commit -m "日志信息"

添加远程仓库
git remote add origin https://gitee.com/camouflage_programmer/code-temple.git

推送到远程仓库
git push -u origin master

gitee推送失败

推送到远程仓库时报错,原因,window默认记住了,你上次提交的用户名和密码
解决:打开电脑的控制面板–>用户账户–>管理Windows凭据
然后删除,gitee的账号信息了。重新提交就行了

remote: WangGang6656: Incorrect username or password (access token)
fatal: Authentication failed for ‘https://gitee.com/camouflage_programmer/code-temple.git/


github推送失败

! [rejected] master -> master (fetch first)
error: failed to push some refs to ‘https://github.com/WangGang6656/project-01.git
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., ‘git pull ...‘) before pushing again.
hint: See the ‘Note about fast-forwards‘ in ‘git push --help‘ for details.

问题原因:远程库与本地库不一致造成的,在hint中也有提示把远程库同步到本地库就可以了。

解决办法:
方法一:使用命令行
git pull --rebase origin master
该命令的意思是把远程库中的更新合并到(pull=fetch+merge)本地库中,–-rebase的作用是取消掉本地库中刚刚的commit,并把他们接到更新后的版本库之中。
出现如下图执行pull执行成功后,可以成功执行git push origin master操作

方法二:
git push -u github master -f
------------------------即可推送

从远程仓库克隆
git clone https://github.com/gildas-lormeau/JSONView-for-Chrome.git

查看日志记录
git log

查看日志记录
git log

然后我们在磁盘中建立一个本地仓库,然后点击右键会出现GIT Bash Here 选项,点击此选项进行操作面板

我们首先配置当前的用户,使用以下的命令:

git config --global user.name 用户命

git config --global user.password 密码

git config --list 查看当前的配置信息

Git常用命令-02

原文:https://www.cnblogs.com/CodeWang666/p/14680030.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!