Olivier Pons
Olivier Pons

Reputation: 15778

How to push manually to another repo once?

Some people talk about "URL's", some people talk about "remotes" and I couldn't find a simple and clear explanation for this.

Here's the idea:

When I'm paid (or whatever), I would like to push manually to another repo once, and I would like that the client sees "clearly" only the pushes I've made for him (= like there are no other pushes/branches).

Here's my configuration:

$ git remote -v show
origin  [email protected]:olivierpons/my_repo.git (fetch)
origin  [email protected]:olivierpons/my_repo.git (push)

How to do this?

Upvotes: 3

Views: 75

Answers (2)

knittl
knittl

Reputation: 265141

You need to have network access to your client's repository. Then it is only a matter of pushing your changes (your branches, to be more precise) to your client's repository:

git push user@client_host:path/to/repository.git local_branch:remote_branch_name

If you do not have access to your client's repository, you can also go the route via an integration repository. A remote repository that both you and your client have access to. You then only push completed or paid work to that repository and your client pulls from there. The command to puplish your work is the same as above, only the url is different.

Having to type the full url every time becomes tiresome, that's where "remotes" come into play. A remote in Git is an alias for a remote repository url. You can easily add one and then use it instead of full urls:

git remote add client user@client_host:path/to/repository.git
git push client your_branch:remote_branch_name

Please note that pushing a branch will push the full history (including all commits) of this branch. This might or might not be a problem in your case.

Upvotes: 1

VonC
VonC

Reputation: 1323203

and I would like that the client sees "clearly" only the pushes I've made for him (= like there are no other pushes/branches).

Then it is best to have:

  • a separate local repository where you do only development for your client
  • a separate GitHub repository, that your client can clone and inspect at will.

Trying to keep multiple works inside the same repository is not a good fit when you want to share only "a part of it" to an external collaborator.

If you really want to push one branch, as in knittl's answer, you need to make sure:

  • it is an orphan branch (no common history, or you would push the history of the previous branch it was created on)
  • no merge was done to it (or you would push the history of the merged branch in addition of your own branch)

Upvotes: 2

Related Questions