git使用方法

 

git config --global user.name "yourname"
git config --global user.email "youremail@youremail.com"

如果需要使用 HTTPS协议在本地与远程仓库之间进行数据传输,可以用以下命令配置客户端记住密码,避免每次都输入密码。

git config --global credential.helper store

要检查已有的配置信息,可以使用 git config --list 命令。

 

ssh-keygen -t rsa -C "dandelion_jsnj@qq.com"
ssh -T git@gitee.com


git clone https://gitee.com/dandelion_jsnj/intelligent-identification.git

或者使用仓库的SSH地址:

git clone git@gitee.com:dandelion_jsnj/intelligent-identification.git

在本地仓库目录中执行命令git remote -v,可以看到本地仓库与远程仓库的关联关系

mkdir local #新建一个文件夹
cd local
git init    #将文件夹初始化成一个gitee本地仓库
git remote add origin git@gitee.com:dandelion_jsnj/intelligent-identification.git #将本地仓库与一个远程仓库关联起来。origin是远程仓库在本地的默认名称,用于指代名称后面的远程仓库地址,也可以用其它名字。

#添加/指定要提交给远程仓库的内容。.表示所有被修改的内容,也可以指定某个文件。
git add . 
#为本次提交添加备注信息
git commit -m "对本次提交的说明" 
#将指定的内容提交给名为origin的远程仓库的master分支。
git push origin master 

#用名为origin的远程仓库的master分支更新本地仓库。
git pull origin master 


https://www.jqhtml.com/8235.html

git status等命令自动着色

git config --global color.ui true                        
git config --global color.status auto
git config --global color.diff auto
git config --global color.branch auto
git config --global color.interactive auto
 
https://www.cnblogs.com/uncleyong/p/10654244.html

第一种方法: 先从远端库拉下来,把本地要加入的代码放到刚刚从远端库下载到本地的库中,然后提交上去,因为这样的话,你基于的库就是远端的库,这是一次update操作

第二种方法:使用这个强制合并的方法

  git pull origin master --allow-unrelated-histories,后面加上--allow-unrelated-histories,把两个不相干的分支进行强行合并,后面再push就可以了

  git push origin master:init,origin是别名(git remote add origin git@gitee.com:uncleyong/test.git),master是本地的分支名字,init是远端要推送的分支名字,本地必须要先add、commit完了,才能推上去

  参考:http://stackoverflow.com/questions/37937984/git-refusing-to-merge-unrelated-histories

       https://dannyhz.iteye.com/blog/2412222

第三种方法:强制push,这样会使远程修改丢失,尤其是多人协作开发的时候,所以慎用。

  git push -u origin master -f



posted @ 2023-04-03 09:03  洪豆豆的记录  阅读(9)  评论(0编辑  收藏  举报