使用Git进行项目的基本管理

  • 前提:已注册GitHub账号,并在GitHub中创建了私有/共有仓库,已经安装Git,使用Windows操作系统
  • 需求:在服务器和终端主机上同步项目
  • 提示:文章质量有待提高,属于基础内容

步骤

  • cd到需要管理的项目下文件夹内, 鼠标右键Git Bash Here, 使用Git init创建工作区
  • 切换用户命令:
git config --global user.email "email address here"
git config --global user.name "user name here"
git config user.email # 查看
  • 产生密钥,随后就会在C:/user/你的账户/.ssh下产生私钥和公钥,公钥在.pub下,用记事本打开后到github账户的设置中添加自己的公钥。
ssh-keygen -t rsa -C "email address here"	# remember to add your public key to your github account
ssh -T [email protected] # 测试
git init    # initialize your repo
git remote add origin https://github.com/GitHub用户名/仓库名.git # 连接到仓库
  • 使用git add 文件(夹),把工作区项目文件添加到暂存区
  • 使用git commit -m ”message“,把项目文件提交到本地仓库中
  • 使用git push origin 分支,把项目文件提交到远程仓库中
  • 参考
    https://www.jianshu.com/p/2e1d551b8261
    https://www.liaoxuefeng.com/wiki/896043488029600/897271968352576
    https://www.cnblogs.com/kinglead/p/10979641.html
  • 真正的基本操作有哪些:
git 初始化
git 添加到暂存区
git 添加到本地仓库
git 分支管理
git 查看状态
git 查看日志
git 查看/注册/切换用户
git 创建远程仓库
git 连接远程仓库
git 添加到远程仓库
git 克隆远程仓库
git 拉取远程仓库
git 远程仓库版本回退
git 多人协作
git 分支合并

其他的事

  • 注意事项:
    git add * 没反应:add大文件,死锁了,解决方法blog
    git add * csv文件时,提示:warning: LF will be replaced by CRLF i,原因是不同操作系统下换行符不同,解决方法:blog
    git push origin master/git push -u origin master弄不上去,先pull后add、commit最后push。

猜你喜欢

转载自blog.csdn.net/BubbleCodes/article/details/124019494