Develumpen

Auto setup remote branch with Git

Every time I create a new branch and try to push it, Git asks to set the upstream branch. This means that Git wants to know which is the remote branch for the current local branch.

The command to set the upstream branch is:

git branch --set-upstream-to <remote-branch>

But I don't want to manually set it every time. In my case, the remote branch always has the same name as the local branch. There is a way to configure Git to use the current branch as the remote branch:

git config --global push.autoSetupRemote true

#git #til

Access Ruby on Rails path and url helpers in console

If you try to retrieve either a _path or _url from the console you'll see an error. You'll have to call the method from the app.

Loading production environment (Rails 7.1.3.2)
irb(main):001> root_url
(irb):1:in `<main>': undefined local variable or method `root_url' for main:Object (NameError)

root_url
^^^^^^^^
irb(main):002> app.root_url
=> "http://www.example.com/"
#ruby on rails

Hi, this is the first ever post on indieblog.xyz

It’s been published using micropublish.net