新用户的话 要在服务器里面运行这2条命令,作用配置用户名和邮箱地址的作用
git config --global user.email ‘2368779914@qq.com’
git config --global user.name ‘lrw’
1.登陆https://github.com注册且登陆相关账号
2.在页面创新得库
3.在服务器里面随便创建一个存放git得目录
#mdkir test
#cd test 进入目录里面
#git clone https://github.com/账户名称/仓库名称
比如git clone https://github.com/liangruiwen941028/test.git 这样会把这个账号里面的test库下载到本地
远程库信息 #git remote -v
origin https://github.com/liangruiwen941028/test.git (fetch)
origin https://github.com/liangruiwen941028/test.git (push)
4.在当前目录新建一个Git代码库
#git init
5.要添加一个新的远程仓库,可以指定一个简单的名字
远程库的名字就是origin,这是Git默认的叫法,也可以改成别的,但是origin这个名字一看就知道是远程库
#git remote add origin https://github.com/liangruiwen941028/test.git
#git push -u origin master 上面命令将本地的master分支推送到origin主机,同时指定origin为默认主机,后面就可以不加任何参数使用git push了。
这个样子服务器就有对于得github上面得得文件。
6.把 github上面得库内容同步更新到到服务器里面
#git pull
7.git add . 当前文件
#add添加新文件
8.提交资料
[root@pc001 ~]# git commit -m “test” 把更新的内容暂时存在暂存区
[root@pc001 ~]# git push 把暂存区的内容提交到github上面
9.查看历史版本
git log
回到到指定版本
git reset --hard XXXXX (这里的XXXX是值git log 看到的commit)
注意
[root@CentOS7 test]# git push
Username for ‘https://github.com’: 2368779914@qq.com
Password for ‘https://2368779914@qq.com@github.com’:
To https://github.com/liangruiwen941028/test.git
! [rejected] HEAD -> master (non-fast-forward)
error: failed to push some refs to ‘https://github.com/liangruiwen941028/test.git’
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. ‘git pull’)
hint: before pushing again.
hint: See the ‘Note about fast-forwards’ in ‘git push --help’ for details.
出现这个提示的话 是要求你保证你是最新的版本
执行git pull
之后再修改文件内容
本文详细介绍了如何在GitHub上创建和管理代码库,包括设置用户名和邮箱、初始化本地仓库、克隆远程仓库、推送和拉取代码等操作流程。

102

被折叠的 条评论
为什么被折叠?



