配置github的用户名和邮箱
git config --global user.name [输入你的用户名]
git config --global user.email [输入你的邮箱]
初始化
git init
添加项目
git add . #添加文件夹内所有文件
git add [文件名] #添加单个文件
将文件提交到仓库
git commit -m "文件备注"
连接github仓库
git remote add master [git仓库地址]
git branch -M master
拉取分支(如果是第一次上传则不用)
git pull master #master是你创建的一个仓库分支,也可修改默认分支
上传到github仓库
git push -u origin master
输入github的登陆邮箱
输入github的登陆密码(token)
注意:登陆密码需要去github设置中生成token再把token复制进去!!!
以下步骤为github中创建 token
打开设置
打开开发人员设置
打开个人访问令牌(生成新令牌)
执行以下步骤即可
等待上传完毕即可在github页面中看到上传到项目
gitee操作
简易的命令行入门教程:
Git 全局设置:
git config --global user.name "你的用户名"
git config --global user.email "你的邮箱"
创建 git 仓库:
mkdir test-items
cd test-items
git init
touch README.md
git add README.md
git commit -m "first commit"
git remote add origin https://gitee.com/saladteam/test-items.git
git push -u origin "master"
已有仓库?
cd existing_git_repo
git remote add origin https://gitee.com/saladteam/test-items.git
git push -u origin "master"
master、origin master 与 origin/master 有什么区别
master 这个很好理解,它代表本地的某个分支名。
origin master 代表着两个概念,前面的 origin 代表远程名,后面的 master 代表远程分支名
origin/master 只代表一个概念,即远程分支名,是从远程拉取代码后在本地建立的一份拷贝(因此也有人把它叫作本地分支)。