天天看点

GIT Hub/gitee 管理代码

1.github/gitee 创建账号并建立任务仓库

2.进入仓库 复制下code里面的地址 等会儿要用

3.到本地项目文件夹右键选择git bash here

4.输入个人信息(代码提交者)

用户名即为你点击自己头像之后下面的那串字母+数字

git config --global user.email  “[email protected]”
           

(码云密码输入错误的话{有时候只能输错一次} 你需要进入“凭据管理器”修改密码(任务栏搜索“凭据管理器”))

5.在本地项目目录创建本地仓库

git init  
           

输入命令后项目目录会有一个隐藏的.git文件夹

6.上传所有代码到本地仓库

git add . (注意add后面有个点,与add之间有一空格)

7.这样就把代码上传到本地仓库了

(引号里面是你本次改动的备注,内容随意)

8.关联本地仓库并上传代码

git remote add origin (https://github.com/Yanyf765/hr_sys.git)

(2步骤复制的地址)

9.(分割)

git push origin master

(推送你的代码到远程服务器端)

报错:(此时报错是正常的 需要先将之前的代码拉取下来 再进行推送)

!!!注意拉取之后 需要重复6-7步骤将代码保存到本地仓库 并且处理掉文件内的冲突 冲突主要来源于服务端文件和本地文件的不同 需要你选择保留本地当前更改还是服务器端传入的更改

10.执行命令:

git pull origin master --allow-unrelated-histories
           

git 在pull或者合并分支的时候有时会遇到这个界面。可以不管(直接下面3,4步),如果要输入解释的话就需要:

1.按键盘字母 i 进入insert模式

2.修改最上面那行黄色合并信息,可以不修改

3.按键盘左上角"Esc"

4.输入":wq",注意是冒号+wq,按回车键即可

之后就可以成功的pull,push了

提交到远程报错,如下:

src refspec master does not match any

原因:

本地仓库为空

解决方法:使用如下命令 添加文件;

$ git add add.php addok.php conn.php del.php edit.php editok.php ftpsql.sql index.php
           

之后在push过程中出现如下错误:

$ git push -u origin master
Warning: Permanently added the RSA host key for IP address 'xx.xx.xxx.xxx' to the list of known hosts.
To [email protected]:hahaha/ftpmanage.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to '[email protected]:hahahah/ftpmanage.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.
           

提示使用 git pull 之后在 push

使用如下命令解决:

$ git pull --rebase origin master
warning: no common commits
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
From github.com:hahah/ftpmanage
 * branch            master     -> FETCH_HEAD
 * [new branch]      master     -> origin/master
First, rewinding head to replay your work on top of it...
Applying: init files
           

继续push,成功。

这是我从网上搜集的一些使用流程和一些问题的解决方法

有问题 欢迎大家留言提问!!!

补充 码云 Gitee 如果需要每次都输入账号密码的话 估计是你的凭据管理器没有保存你的码云账号密码

在你的计算机搜索凭据管理器

地址输入:https://gitee.com/

用户名和密码即为你的账号密码

此时应该就不需要每次提交的时候输入账号密码