Me and a couple of other guys from a big team are working on a separate page on the project. Let's call it groups page. While we work on the groups page, we need to exchange incomplete code, the code we wouldn't want to be sent to the central repo. And during this time, we also work on features not related to groups page, we do need to commit and push to the central server. I am looking at solutions for this problem, here are my ideas. Please comment on them.
We can't make a branch in the actual repo server because of the higher ups.
Now each of these has problems.
You do not need to push from one bare repo to another. Git works by pushing from your local repo, to one or more remote repos. When you clone, there's a default remote repo called "origin". But you can have as many remote repos configured as you want.
To push the commit from the local repo to your remote repositories, run git push -u remote-name branch-name where remote-name is the nickname the local repo uses for the remote repositories and branch-name is the name of the branch to push to the repository. You only have to use the -u option the first time you push.
In order to clone your repository to create a new bare repository, you run the clone command with the --bare option. By convention, bare repository directory names end with the suffix . git , like so: $ git clone --bare my_project my_project.
3 is your best option. In fact, that's really how Git is intended to be used; with repositories for individual components, which feed into a more central repository when work is done.
There is no problem pushing someone else's changes. Lets say you make a change, and push it to the groups page repository. Then I pull that, make some changes, and push them back. Now we decide we're done. If I push to the central repository, that push will include both my changes, and your changes which my changes were based on.
You do not need to push from one bare repo to another. Git works by pushing from your local repo, to one or more remote repos. When you clone, there's a default remote repo called "origin". But you can have as many remote repos configured as you want. To set this up, let's say you have cloned from the central repo; that's called "origin". Now you create a bare repo: it's at ssh://some-machine.corp.com/path/to/groups-repo.git
. In your local working repo, just do git remote add groups ssh://some-machine.corp.com/path/to/groups-repo.git
, and you will have a reference to that groups repo. Now you can use git fetch
, git pull
, git push
and so on with groups
as well as with origin
.
Is there a way to push from one bare clone to the main github repo?
Yes, you don't have to be in a work tree to push changes from a bare repo.
Simply ssh to the place where you 'local master' is, and run:
git push origin master
As the other answer point out, you can also push directly from your local copy to a remote master, but it's sometimes more convenient to have an automated 'gatekeeper' repository like this that can be triggered to push changes out (eg. after review) to multiple remote repositories via automation, without worrying about setting up ssh keys and so forth for a specific individual to push the changes out.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With