git woes: cloning locally - [remote rejected] master -> master (branch is curren

First - I don’t like and don’t understand Git. Second - I don’t have that much time to learn it. Sorry, but such people exist.

In Mercurial to start working on a new patch I usually do:

hg clone local-clone new-patch-clone  
cd new-patch-clone  
vim scripts/linux/template/Makefile  
hg ci  
hg push  

Pretty intuitive, no? This will push the patch to local-clone. If you have rights to push upstream, you can cd to local-clone and invoke hg push there. That’s all to make your patch shared.

Before anybody will teach their ways, I must say about my workflow. I usually work on several features at once and keep each feature in its own directory. I don’t like to waste energy with command line tools each time I need to check which feature is currently available in current checkout. My editor shows me the current path and that is more than enough.

Now I am trying to do the same with Git:

git clone openFrameworks ofg  
cd ofg  
vim scripts/linux/template/Makefile  
git ci  
  git: 'ci' is not a git command. See 'git --help'.  
git commit  
git push  
 remote: error: refusing to update checked out branch: refs/heads/master  
 remote: error: By default, updating the current branch in a non-bare repository  
 remote: error: is denied, because it will make the index and work tree inconsistent  
 remote: error: with what you pushed, and will require 'git reset --hard' to match  
 remote: error: the work tree to HEAD.  
 remote: error:   
 remote: error: You can set 'receive.denyCurrentBranch' configuration variable to  
 remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into  
 remote: error: its current branch; however, this is not recommended unless you  
 remote: error: arranged to update its work tree to match what you pushed in some  
 remote: error: other way.  
 remote: error:   
 remote: error: To squelch this message and still keep the default behaviour, set  
 remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.  
 To /home/user07/openFrameworks/  
  ! [remote rejected] master -> master (branch is currently checked out)  
 error: failed to push some refs to '/home/user07/openFrameworks/'  

WTF? No, bad question. What should I type now to push my change to local clone at openFrameworks/ and then to GitHub to create a pull request for review? I can’t push from ofp/, because it was cloned from local copy and doesn’t know about remote and I don’t feel like copy/pasting GitHub URL every time I need to push there.

i don’t really know mercurial, but here’s the ‘official’ guide to contributing to OF

but i’d be glad to take some time to explain it again. here’s what it looks like if i want to contribute on a fresh account + computer:

// create a github account  
// go to []( and click the 'fork' button  
git clone // auto adds remote named 'origin'  
git remote add upstream git:// // manually add remote named 'upstream'  
git checkout -b feature-SomeNewFeature upstream/develop // create and checkout a branch based on upstream/develop  
// make your changes  
git add . // add the files you've changed  
git commit -m "added some new feature"  
git push origin develop // pushes your changes to the github repo  
// go to github and click 'pull request'  
// click 'edit commit range' and make sure it's being pulled into develop, not master  

some of the commands i wrote above are unnecessarily verbose, but i thought it would be better to be clear. maybe the most important thing you’re missing is that pull requests happen on the web interface, not via the command line.

yes, +1 to all kyle said. it doesn’t make much sense in git to clone the whole repository to work on a new feature.
At the end of the link he provided there are some links to basics about git and github usage. Very informative, doesn’t take much time to get you up to speed on how to work with it.

[quote=“bilderbuchi, post:3, topic:7983”]
yes, +1 to all kyle said. it doesn’t make much sense in git to clone the whole repository to work on a new feature.[/quote]

What do you do then, when you clone the repository from GitHub? )

I explicitly explained my DVCS workflow in hope that people won’t try to teach me their proper way. But if you object I can explain once more why having separate directory for each feature is convenient:

  1. every time you cd, you know what feature you’re working on - there is no needless state in your head
  2. i know IDEs that show the name or project folder in project explorer, but I don’t know any that shows you the current branch you’re working on
  3. if you badly messed your working copy with merges, branches and reverts - you lose only one piece of work if you decide to do the checkout from scratch (especially actual if you work with some magical system like Git)

I’ve got an impression that Git imposes too much on development workflow. I’m not an artist, but ISTM that it is too complicated for an artist, too magical and constraining.

Can anybody just help me to fit Git into my preferred workflow? Does anybody understand at least why it doesn’t allow me to push back into local clone (which is no different from remote, right)?

[quote=“techtonik, post:4, topic:7983”]

Get some source code to work with onto your machine…

Well I can acknowledge that it may be more convenient for you to have the repo structure in folders, but I still don’t see why it would be prefereable - you have lots of folders on your machine, folders show neither nested structure nor history, and you duplicate lots of files, bloating the size of your code base by a factor NrofBranches.

IDE: Have you tried Eclipse with Egit?

Well, if it all is already in your git tree, normally the rule of thumb is you can recover any situation. Most probably, it’s just a git reset --hard away…

more magical and constraining than hg? also, what does ISTM mean?

yes. it says so in your first post: “refusing to update checked out branch:”. I never encountered this situation before, but it’s probably a good idea to check out a different branch in your parent repo, and try again.

In conclusion, let me say that we don’t want to force “our proper way” onto you. You ask how to work with git, we tell you. You are of course free to adopt your own working method, and we showed you resources that help you develop this workflow with git. Especially, I want to highlight stackexchange. nearly every question/problem I ever had about git was answered/solved there…

When you only have 15 minutes for a change, time is more valuable than space.

My experience with Eclipse on Linux was not very pleasant. It required some custom Java version, was slow and I’ve abandoned it.

This command doesn’t sound like it was designed to preserve your patches in repository. =)

It Seems To Me. I can’t say that hg is not magical and constraining, but 1. I already know it, 2. it allows to work with Git repositories when they don’t misbehave for some magical reason reported here.

Maybe there is a problem with Git on my machine? Can you acknowledge the behaviour I experience by repeating my Git session in the first message? What command would you add to the list to avoid the error and make it possible to do ‘git push’ upstream?

Thanks. I know this sounds impolite, but I don’t want to learn Git. I just want to send patch for Makefiles I’ve created a week ago and make sure I will be able to do so in future (meaning I can remember how to adopt this Git thingie to my usual workflow).

2 terse answers, I’m short on time:

  1. why don’t you use hg to push to github?
  2. can’t reproduce your error right now, but others can, and the answer is on stackexchange - checkout another branch in your parent repo before pushing to it (as I recommended before)
    (and btw, you would probably have found that like I did, by copy-pasting the error into the search field on stackoverflow.)

ok, 3) I don’t know when you tried Eclipse, but I use the current one (indigo) on ubuntu, and neither did i have to install another java, nor did i experience any undue slowness. probably not as fast as vim, though… :stuck_out_tongue: