0

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
merlin2011
  • 71,677
  • 44
  • 195
  • 329
Omar
  • 3
  • 2
  • Correct in what sense? – Maroun Feb 22 '16 at 19:57
  • if i follow this order of this steps i can have problems or not?the idea is i want to have the latest version from master without losing my updates in the code and then pushing the latest version with my updtes in my branch – Omar Feb 22 '16 at 20:04
  • I usually don't merge master into my branch, see git workflows (google) to see which workflow works best for you or your team – Luke Hutton Feb 22 '16 at 20:04
  • so it is correct to do add then commit then pull then push? – Omar Feb 22 '16 at 20:16
  • It could be correct for you, it depends on your workflow. – Luke Hutton Feb 22 '16 at 20:26

1 Answers1

0

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>
Community
  • 1
  • 1
CodeWizard
  • 128,036
  • 21
  • 144
  • 167
  • Cool. glad to help. Rad this out to get some more usefull information. http://stackoverflow.com/questions/34519665/how-to-move-head-checkout-revert-reflog-reset/34519716#34519716 – CodeWizard Feb 22 '16 at 20:38