把自己分支合并到Dev分支
git add . # 提交到暂存区
git commit -m "提交备注" # 把暂存区文件提交到本地仓库
git push 自己分支名 # 本地上传到远程分支
git checkout dev # 切换到dev分支
git pull # 拉取dev最新代码
git checkout 自己分支 # 切换到自己分支
git merge dev # 合并dev代码,解决冲突,此刻自己分支代码是最新的
git push
git checkout dev
git pull
git merge 自己分支 #为确保不会丢失代码,在将自己分支代码合并到dev
git push # 现在dev和自己分支都已是最新代码
git branch -a # 查看远端分支
git push origin test:test // 提交本地test分支作为远程的test分支
git push origin --delete branch_name // 删除远程分支
git reset --soft HEAD^ # 撤销commit但未push的操作
远端branch和tag同名的时候,删除方法
git push origin :refs/heads/branchName //删除远端branch
git push origin :refs/tags/tagName //删除远端tag
# 定义对所有用户都生效的命令别名
alias gitp1='git checkout dev && git pull && git checkout zhouxia && git merge dev && git push && git checkout zhouxia'
alias gitp2='git checkout dev && git pull && git merge zhouxia && git push && git checkout zhouxia'
alias # 查看所有命令别名,可看到gitp1,gitp2
# 现在就可以直接输入别名来执行命令了
# 上面直接在命令行添加是临时的,下面是永久生效
vim ~/.bash_profile # 在文件最后添加别名后保存
source ~/.bash_profile
alias gitp1 # 可查看别名为gitp1的命令
# 拉取远程分支并同时创建对应的本地分支 (git checkout -b 要创建的本地分支名 origin/要拉取的远程分支名)
git checkout -b nan-v0.1.1 origin/dev-bbtc/v0.1.1
git branch mybranch # 创建分支
git checkout mybranch # 切换分支
git checkout -b mybranch # 创建并切换分支
git rebase master # 更新master主线上的东西到该分支上
git branch -d mybranch # 删除分支
git branch -D mybranch # 强制删除分支
mkdir goserver
cd goserver
git clone -b zhouxia ssh://git@git.shining3d.com:10022/cloud3d/gdocserver.git ./ # 要加./ 否则git会自己再建个目录,-b 指定拉取的分支
git branch -r # 查看分支信息
git pull # 拉取项目
git checkout 分支名 # 切换到自己的分支
git pull # 拉取分支项目
shining3ddeMacBook-Pro-2:gdocserver shining3d$ git branch
* dev
zhouxia
shining3ddeMacBook-Pro-2:gdocserver shining3d$ git pull
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.
git pull <remote> <branch>
If you wish to set tracking information for this branch you can do so with:
git branch --set-upstream-to=origin/<branch> dev
shining3ddeMacBook-Pro-2:gdocserver shining3d$ git merge zhouxia
Already up to date.
shining3ddeMacBook-Pro-2:gdocserver shining3d$ git push
fatal: The current branch dev has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin dev
shining3ddeMacBook-Pro-2:gdocserver shining3d$
shining3ddeMacBook-Pro-2:gdocserver shining3d$ git push --set-upstream origin dev
Total 0 (delta 0), reused 0 (delta 0)
remote: . Processing 1 references
remote: Processed 1 references in total
To ssh://git.shining3d.com:10022/cloud3d/gdocserver.git
2c5bf09..a6b4e8d dev -> dev
Branch 'dev' set up to track remote branch 'dev' from 'origin'.
shining3ddeMacBook-Pro-2:gdocserver shining3d$ git checkout zhouxia
Switched to branch 'zhouxia'
Your branch is up to date with 'origin/zhouxia'.
shining3ddeMacBook-Pro-2:gdocserver shining3d$
git restore 文件名 # 丢弃工作区的修改
git 标签tag使用参考:https://www.cnblogs.com/pinefantasy/articles/6287165.html
git下查看登录的用户名邮箱
git config user.name
git config user.email
git config --global user.name "username" ## 修改git用户名为username
git config --global user.email "email" # 修改git登录邮箱为email