2

I'm making changes to the Linux kernel for my particular ARM board.

I've cloned this repository: http://arago-project.org/git/projects/?p=linux-am33x.git

I want to commit the changes I've made, and push them, but to my own server, not to the arago server. I'm currently doing a diff on my work directory and committing the diff to my own server side repo. Is there a more elegant approach to this?

Note that I'd like not to clone the entire arago repo on my server. The changes I'm making are trivial, this repo is not. Based on the answers below, I've done this:

$ git remote add myrepo ...`
$ git fetch myrepo
$ git checkout -b mybranch origin/v3.2-staging
$ git push myrepo mybranch

I was expecting that nothing would be uploaded, since nothing has been committed yet. But all of v3.2-staging started getting uploaded. What I want to do, is to commit my local changes to mybranch. And only that should get pushed to myrepo/mybranch. What kind of checkout will permit this?

diskless
  • 23
  • 1
  • 5

3 Answers3

3

Assuming the branch you are on is mybranch and the remote you want to hit you will call myremote

  • Add the remote
    git remote add myremote [GIT_URL|PATH|URL|SSH-LINE]
  • Push your branch (and potentially any changes to it)
    git push myremote mybranch

You then have to choose and manage yourself which you want to check out from or track in the future

  • If you later want to fetch ALL of your remotes together instead of git fetch do git remote update

  • If you want to continue to keep myremote/mybranch synchronized with an upstream origin/upstream branch but push it to myremote/mybranch then you will be best served by altering the config so that it pushes by default to myremote :
    git config remote.origin.pushurl user@user.com:repo.git (Checking for better way to do this part)

Suggest that you take a read of the working with remote repo's section of the git-book http://git-scm.com/book/en/Git-Basics-Working-with-Remotes

UpAndAdam
  • 4,515
  • 3
  • 28
  • 46
  • Thanks. The book link is useful. It will help me "actually know what I'm doing" with git, a concept I don't always follow :p – diskless Oct 16 '13 at 14:07
  • Highly highly highly recommend reading it or at least skimming it – UpAndAdam Oct 16 '13 at 14:13
  • OK, so I did the following: `$ git remote add myrepo ...` `$ git fetch myrepo` `$ git checkout -b mybranch origin/v3.2-staging` `$ git push myrepo mybranch` I was expecting that nothing would be uploaded, since nothing has been commited yet. But all of v3.2-staging started getting uploaded (I think). What I want to do, is to commit my local changes to mybranch. And only that should get pushed to myrepo/mybranch. – diskless Oct 16 '13 at 14:21
  • @diskless It did exactly what it should have. You checked out a local branch called `mybranch` based upon the contents of `origin/v3.2-staging` (and depending on your config also tracking it). You then pushed this branch to your `myrepo`. If it didn't already exist there it would upload this branch to that repo. Whether you have committed anything yet to your local branch or not is irrelevant, what's relevant is only whether that branch existed on the remote you are pushing to and if it would be a fast-forward merge. – UpAndAdam Oct 16 '13 at 14:28
  • @diskless I amended my answer to highlight that I think you got tripped up by "your changes"; effectively your changes the first time is the branch's existence. – UpAndAdam Oct 16 '13 at 14:32
  • understood. How can I continue to track the changes to v3.2-staging on the arago server, while only pushing my commits only to myrepo? – diskless Oct 16 '13 at 14:32
  • Assuming what you are saying is "keep your branch up to date with respect to the upstream `origin/v3.2-staging`" then you will want to set it up such that you fetch and merge `origin/v3.2-staging` into your branch and then push your branch to `myrepo`. This is already answered here: http://stackoverflow.com/questions/4523496/is-it-possible-to-pull-from-one-repo-and-push-to-other-one . Again I would suggest reading a bit more to understand what you are doing. – UpAndAdam Oct 16 '13 at 14:42
0

Use

git format-patch -1 <commit_SHA>
Tronum
  • 707
  • 3
  • 13
-1

add your server as a new remote, using git add remote; then when you push/pull you can specify which server you communicate with.

You may also want to change the default remote using git config to change master.remote and master.merge (git actually allows different defaults for push and pulls, which you may want to use here).

Oliver Matthews
  • 7,497
  • 3
  • 33
  • 36
  • Ah, this looks _exactly_ like what I needed. Let me research `git add remote`. And it would be great to `pull` and `push` to different servers. Thank you so much! – diskless Oct 16 '13 at 14:03