# git-example **Repository Path**: lyric-li/git-example ## Basic Information - **Project Name**: git-example - **Description**: 记录 Git 一些使用方法 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2019-05-20 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## Git Example > 记录 Git 一些使用方法 ### 常用命令 - 设置Git的user name和email,查看公钥,生成公钥 ``` # 设置Git的user name和email git config --global user.name "test" git config --global user.email "test@a.com" # 查看公钥,生成公钥 cd ~/.ssh ssh-keygen -t rsa -C "test@a.com" ``` - 克隆代码,拉取更新,添加,提交,推送,拉取更新,切换分支,合并分支 ``` # 克隆项目 git clone http..xxx.git # 拉取主分支最新代码 git pull orign master # 添加代码 git add --all # 提交代码 git commit -m "desc" # 代码推送,主分支 git push origin master # 代码推送,自己的分支 git push origin mybranch # 新建分支 git checkout -b newbranch # 切换分支 git checkout oldbranch # 查看当前所有分支 git branch # 查看代码提提交的情况 git status # 将其他分支合并到当前分支 git merge origin/otherbranch ```