1、初始化
rm -rf .git
git init
git remote add origin https://xxx.xxx.git
git remote add origin https://may_lv_at2plus@bitbucket.org/at2plus/tfs-dev-env.git
git add .
git config --global color.ui true
git commit
git push -u -f origin master
2、仓库,分支
git fetch --all 拿到所有的分支
git branch --all 查看所有的分支
git branch 查看在哪个分支
git remote -v 查看仓库
git remote add upstream https://may_lv_at2plus@bitbucket.org/at2plus/tfs-explorer.git 添加远程仓库
git pull --rebase upstream master 从master里面拉取数据
git checkout . 还原文件
git push origin master 向origin中传文件
git checkout -b create-login-page 创建分支
git checkout master 切换分支
3、提交代码
情景一
先提交到分支,再合并到master
git branch (create-login-page)
git add .
git commit -m "login page"
//先push到分支上
git push origin create-login-page
//切换到master分支
git checkout master
git merge create-login-page
情景二
拉取代码
git pull 本地有修改,不能merge的问题
第一种方法,本地提交后再进行merge操作。
git commit -m "log内容"
git merge
这样提交后再去merge可能需要处理冲突
或者放弃本地修改后更新:
git reset --hard
git pull
情景三
撤销commit,不更改代码
git reset --soft HEAD^
情景四
push代码
撤push
git reset --hard <版本号>
git push origin <分支> --force