1. 远程先开好分支后拉到本地

检出远程的feature-branch分支到本地
git checkout -b feature-branch origin/feature-branch

2. 本地先开好分支然后推送到远程

创建并切换到分支
git checkout -b feature-branch
git push origin feature-branch:feature-branch
推送本地的feature-branch(冒号前面的)分支到远程origin feature-branch(冒号后面的)分支(没有会自动创建)

3. push 到远程仓库上面

git push origin hello_git_branch
这里的含义是将hello_git_branch这个分支提交到远程仓库上面。如果远程仓库没有这个分***么也会新建一个该分支。

4. error:failed to push some refs to

解决
git pull --rebase origin master
git push origin master
进行push前先将远程仓库pull到本地仓库
git pull origin master #git pull --rebase origin master
git push -u origin master

5. git使用.gitignore忽略提交文件并没有生效问题解决

先把本地缓存删除(改变成未track状态),然后再提交:
git rm -r --cached .
git add .
git commit -m “update .gitignore file”