git Push changes to two remotes separately -


how can have 1 working directory on local machine , push chanegs 2 different remote separately?

i've set 2 git repositories on server dev , main. whenever make changes on machine, i'd push changes dev or main.

fyi, using git deploy code. (i followed this instruction set up.) have website , i'd push changes first dev client can take look. if changes ok, want push changes main deploy changes.

here have done far.

  1. cd project directory on local machine.
  2. git init
  3. git remote add dev me@myserver.com:/var/git/dev.git
  4. git remote add main me@myserver.com:/var/git/main.git

however, when make changes , try push either repo (git push dev master), following error.

to me@myserver.com:/var/git/dev.git  ! [rejected]        master -> master (non-fast-forward) error: failed push refs 'me@myserver.com:/var/git/dev.git' prevent losing history, non-fast-forward updates rejected merge remote changes (e.g. 'git pull') before pushing again.  see 'note fast-forwards' section of 'git push --help' details. 

when git pull, get

fatal: no remote repository specified.  please, specify either url or remote name new revisions should fetched. 

i think not understanding basics of git. able me?

a pull fetch followed merge. when perform fetch need specify remote fetching, try

git pull dev 

or

git pull main 

note maintaining pushes different repos tricky. better approach setup branch each (with default remote) , handle merges locally.

git checkout -b main main/master git checkout -b dev dev/master

your work cycle bit like:

<do work on master> git checkout -b dev git pull git merge master (or specific commits want). git push <get client approve, assuming does> git checkout -b main git pull git merge dev git push <go master> git checkout -b master 

look cherry-picking in git manual how handle merging specific commits.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -