如何推进我的分支并从主git中拉出来

时间:2016-02-22 19:56:05

标签: git push pull

遵循以下顺序是否合适:

git add [file names]
git commit [comments]
git checkout master
git pull
git checkout [my branch]
git merge master
git push

1 个答案:

答案 0 :(得分:0)

如何能够推送到不同的分支名称?

你几乎就在那里,但是你错过了一些重要的步骤:

# Add the desired files to stage area
git add [file names]

# commit the changes
git commit [comments]

# switch to master branch
git checkout master

# git pull
# This is dangerous !!! if you are using git version <2.0

阅读here原因(第一段)。

如何以简单的方式完成:

# Commit changes to your local branch 

# pull changes from the remote branch to your branch
# since you are already on your branch - you dont need to switch 
# to master branch. Simply grab the remote copy and merge it into
# your local branch using the pull command.
git pull origin master

# now your changes are merged with master
git push origin <branch_name>