查看电脑是否安装git,打开终端,输入git,回车如果输出如下,则代表已安装了git
如果未安装,则到官网下载 Git
一路next就可以。
安装完成,打开cmd查看git:(输入命令:git --version 可查看当前git版本)
配置用户名和邮箱
$ git config --global user.name "Your Name"
$ git config --global user.email "email@example.com"
使用 --global 修饰后设置的全局的用户,如果设置单个项目的用户,可cd到项目根目录下,执行如下命令:
$ git config user.name "Your Name"
$ git config user.email "email@example.com"
使用命令:git config --list 可查看当前用户信息以及其他的一些信息
$ git config --list
core.excludesfile=/Users/mac/.gitignore_global
difftool.sourcetree.cmd=opendiff "$LOCAL" "$REMOTE"
difftool.sourcetree.path=
mergetool.sourcetree.cmd=/Applications/SourceTree.app/Contents/Resources/opendiff-w.sh "$LOCAL" "$REMOTE" -ancestor "$BASE" -merge "$MERGED"
mergetool.sourcetree.trustexitcode=true
http.postbuffer=524288000
https.postbuffer=524288000
user.email=你的邮箱@qq.com
user.name=你的用户名
macdeMacBook-Pro:~ Artron_LQQ$
$ git init
$ git add .
git add . (注意,后面有个点)表示添加目录下所有文件到缓存库,如果只添加某个文件,只需把 . 换成你要添加的文件名即可;
$ git commit -m "添加你的注释,一般是一些更改信息"
$ git remote add origin 你的远程分支
上传代码到远程库,上传之前最好先Pull一下,再执行命令:
$ git pull origin master
$ git push origin master
$ git branch newbranch
$ git branch
输出:
* master
newbranch
*代表当前所在的分支
$ git checkout new branch
输出:
Switched to branch 'newbranch'
master
* newbranch
$ git add .
$ git commit -a
可使用git status查看提交状态
$ git checkout master
$ git merge newbranch
$ git push -u origin master
$ git branch -D newbranch
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有