简体   繁体   中英

how to push in my branch and pull from master git

Is it appropriate to do the following sequence :

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

How to be able to push to different branch name?

You are almost there, but you miss some important step:

# 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

Read here why (first paragraph).


How to do it in a simple way:

# 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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM