3

We have one internal remote repository in stash and one repository in github for our third party consultants. We try to synch the repository in "Atlassian Stash" to the repository in GitHub everyday. The procedure I follow is to change the remote to github using set url and pull from github (the branch I desire) to my local directory and then I change the remote again to "stash" and push the changes there from my local directory. Is this a good approach or there is a better way to do it?

4
  • 1
    You could use server-side hooks to do the same thing, but automatically. git-scm.com/book/en/Customizing-Git-Git-Hooks#Server-Side-Hooks Commented Jun 3, 2013 at 15:59
  • using the term 'stash' in your context can be confusing as there is a command git stash which is usually short-handed to just stash Commented Jun 3, 2013 at 17:07
  • 3
    Why don't you just setup two remotes (one pointing to your internal 'remote' repo and one pointing to your github one)... no need to set-url to change the location for every push/pull Commented Jun 3, 2013 at 17:08
  • possible duplicate of Different default remote (tracking branch) for git pull and git push Commented Jun 3, 2013 at 18:59

2 Answers 2

1

As @g19fanatic says, no need to keep changing the remote URL's. Just

git pull <name of stash remote> git push <name of github remote> 

You need two separate remotes for this; add the second one if needed with git remote add

Sign up to request clarification or add additional context in comments.

2 Comments

Hi Thanks for your comment, so should I also add and commit before pushing it to the github remote or it will merge automatically?
@vkaul The pull operation includes a merge step. There's no need to add and commit files you've just "pulled" before "pushing" them.
1

You can use a hook for that.

You may push to the second repo when the first one triggers post-receive

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.