前端基础14:Git简单操作
常用的linux命名
cd进入文件夹
cd ..返回上级文件夹
ls -al查看所有的目录 (包含隐藏文件)
mkdir 文件夹名 新建文件夹
touch 文件名 新建文件
vi 1.txt编辑文件
- 按
i进入编辑状态
- 编辑完后按
esc退出编辑,按:wq保存退出(通常用esc后shift+zz·) ;按:q不保存退出(通常用esc后shift+zq);
q!强制退出
cat 1.txt查看文件
rm -rf 文件名 删除文件
pwd查看当前文件目录
配置git 提交远程服务器github
git config --global user.name"你的用户名"
git config --global user.email"你的邮箱"
-git config --list 是否配置成功
git config credential.helper
初始化git仓库
git init
####GIT使用
- 查看提交状态
- 由工作区提交到暂存区
- 由暂存区提交到历史区
本地仓库和远程仓库关联
git remote add origin + 地址 关联
- eg:
git remote add one $ git remote add one https://github.com/wangjingtao68425/testgit.git
git remote -v 查看关联的远程仓库
git remote remove 名字 移除关联的远程仓库
git push origin master 将本地仓库文件同步到远程仓库
处理本地仓库和远端仓库不同的情况
git pull one mater 把远程仓库的内容拉取到本地仓库
- 第一次拉去时若拉取不下来,可以加一个参数
git pull origin master --allow-unrelated-histories
- eg:要提交本地仓库c.txt
- 1 .
git pull one mater
- 2 .
git add .
- 3 .
git commit -m ""
- 4 .
git push one master
克隆远程仓库
git clone https://github.com/wangjingtao68425/testgit.git 相当于创建本地仓库testgit并且让本地仓库和远程仓库关联起来