How can I push a local Git branch to a remote with a different name easily?
I've been wondering if there's an easy way to push and pull a local branch with a remote branch with a different name without always specifying both names.
$ git clone myrepo.git
$ git checkout -b newb
$ git commit -m "Some change"
$ git push origin newb:remote_branch_name
Now if someone updates remote_branch_name, I can:
$ git pull
And everything is merged / fast-forwarded. However, if I make changes in my local "newb", I can't:
$ git push
Instead, I have to:
% git push origin newb:remote_branch_name
Seems a little silly. If
git-config branch.newb.merge to determine where to pull from, why couldn't
git-push have a similar config option? Is there a nice shortcut for this or should I just continue the long way?
I merged my local feature branch “navDrawer” into my copy of the remote “dev” branch. When I sync’d “dev”, it also created a remote “navDrawer” branch. Now I have 3 remotes (master, dev, navDrawer). H
I am working on a local git repository. There are two branches, master and feature_x. I want to push feature_x to the remote repo, but I do not want to push the changes on the master branch. Will a gi
I have a local branch which is a new branch called A. I want to push it to the remote, but I want it to be named differently in the remote. For example, remote name would be users/me/A but in local,
I have a local Git repo that I would like to push to a new remote repo (brand new repo set up on Beanstalk, if that matters). My local repo has a few branches and tags and I would like to keep all of
In my git repository local branch, it is behind by 9 commits. Can you please tell me how can I advance it by 1 commit? # Your branch is behind 'my-git/remote' by 9 commits, and can be fast-forwarded.
How do I push changes from a local git branch to an existing non-master remote branch? If I do a git push, it tries to push changes in all local branches to the remotes they are tracking.
I mistyped a git command which resulted in the creation of a local branch called, '--track'. I've tried the following: git branch -m --track delme (this renames the current branch to delme, not the br
I cloned a friend's git repository to my workstation. I then created my own branch and started working on it. I have also been given the ssh private key of the remote repository where I originally clo
Sometimes by mistake some of users tend to push their local branches to a remote repo creating a new branch on the remote repo. How can we disallow the users to create new branches on a remote repo bu
How can I create a new branch and push it to the remote and then share it with the other developers? I'm following the below steps. What's wrong, missing? Developer A creates the following: git branch
This question already has an answer here: Force Git to overwrite local files on pull 25 answers I want to sync the local branch with the remote git branch. I tried to do git pull but it fails w
I cannot remove a remote branch called origin/featureBranch. I guess it's because the branch name starts with origin, but I am not sure: $ git branch -r | grep featureBranch origin/origin/featureBranc
I come to you because I have this really annoying issue. In xCode, I deleted some files and now, when I want to push my sources, it says that I can't since there is some uncommitted change. The uncomm
All the remote branches are visible as remotes in my local git repository after a git fetch. How to selectively remove the remote branches in my local repository(not in the remote repository).
I did a bunch of work on a local master that I decided needed a new branch. I created a branch diffraction on a machine at work and pushed it: $ git checkout -b diffraction $ git push Then I went to
I tried to push changes in my local branch(local_dev) to a remote branch(develop), I used below command, but it gave me an unexpected message after executing the command. $ git push origin local_dev :
I have created a new user who will be in charge of backing up/syncing the 'origin' remote with another remote we've called 'backup'. Our Origin remote is on our lcoa network and the backup remove is h
This question already has an answer here: Default behavior of “git push” without a branch specified 11 answers Is there a way to configure git to default push my current branch to the origin? E
Is there a shortcut to tell Git to push the current tracking branch to origin? Note: I know that I can change the default push behavior, but I am looking for an ad-hoc solution that does not change th
I worked on some code on a local branch and then I pushed it to a remote test repository with this command: git push origin fix_vouchers:fix_vouchers I'd like to change the active brank on that remot
I have 2 git repositories set up, and I did a lot of coding in 1. Someone else grabbed the code to make changes to the code, but never pushed them up. The changes are now so large, I want to push it t
Alright I did a little bit of research on this but I couldn't find an exact answer, so I have to ask. I have 2 remotes: origin and repo2. I'd like to do something like git pull repo2 master But this
In a git repository, a remote branch I am not tracking was deleted. When I type git branch -r the deleted branch still shows up (and I can check it out) What git command do I have to run to update th
I have a local develop branch dev and a remote master branch. For the dev branch, I have a quite complicated commit history(nearly 20 successive commits). I tried to use git rebase -i origin/m
To delete a local branch in git I use git branch -d, but how do I safely remove a remote branch? I would like to delete it only when the remote branch is merged to my current branch.
I've been working on a local clone of a remote git repository, committing my changes to my local master branch. Now, I want to push my commits to the remote repository. However, I want to keep my loca
I created a branch notmaster to commit as well as push some changes. When I was finished with that branch, I merged the changes back into master, pushed them out, and then deleted the local notmaster.
So I'm working with another developer and want to pull and push to a remote branch (that is not the remote master by the way) but I want to set up so that when I check out my local branch on my machin
I tried looking for a an answer to this, but couldn't find any which address this specific need. Which is weird. I want to be able to do the following: create a local branch based on some other (remo
I have a deploy branch which differs from my master in that it contains various server-only asset files that I don't want polluting my master in development but I would like pushed to master on my ser
Say I'm currently working on a new feature which I've branched off of the 'dev' branch and I've been working for several days and it's not yet ready to be merged with 'dev' and pushed. Although I have
I sometimes want to use the current branch name to use in git commands. For example git push origin feature/really-long-branch-name Is there a git command that will give just the branch name so I can
I have 2 branches local and remote like below. # dev master Right now I have merged changes local using git checkout master & git merge dev. It works great. Using git status I got below: Your bra
I could use a hand with learning how to push a local branch to a remote branch. Please see below. Help much appreciated! The local branch was created after cloning the repo then doing $ git checkout -
Is there any way to block code push directly to master ? I tried by adding a script in .git/hooks/update #!/bin/sh if [ $USER != git-repo-admin ]; then if [ $1 == refs/heads/master ]; then echo M
This question already has an answer here: Git reset --hard and a remote repository 2 answers I have a local git repo on my workstation which I push to a dropbox location so that I can pull it d
I am trying to checkout a remote branch: Somebody pushed a branch called test with git push origin test to a shared repository. I can see the branch with git branch -r. But how can I get this branch?
When I git branch -a | grep my_funny_branch it gives remotes/origin/my_funny_branch But when I git branch -d -r origin/my_funny_branch it gives error: remote branch 'origin/my_funny_branch' not foun
I created a local branch which I want to 'push' upstream. There is a similar question here on Stack Overflow on how to track a newly created remote branch. However, my workflow is slightly different.
Is there a good way to see when or all local branches which has been setup to track a remote branch where the remote branch has been removed? example. I track the remote branch hotfix and it is remove
I merge branch A with branch B, and delete branch A. When I tried the same thing in remote repo: delete branch A, I got an error like this: fajar@FAJAR-PC /e/project minggu ini/ProjectTesis (master) $
Is there shortcut that will allow to push to selected branch? It can be a command, or something similar: git push branch that will run this code: git push origin $(git branch | grep '*' | sed -e 's/*
I have cloned project from master branch from remote repository remote_repo. I create new branch and I commit to that branch. Other programmers pushed to remote_repo to master branch. I need now to re
I have made a local branch called develop and have made some changes to it. However I now want to merge another developers changes to remotes/devteam/master into my develop local branch. How best do I
I've seen from How do I change the author of a commit in git? how to change my email in my commits; however, when I try to push it, I get this error: $ git push production master To git@<remote_ser
When I attempt to push to my heroku.com remote git repository, i get this message: ssh: connect to host heroku.com port 22: Connection refused I can easily work with my repository on github with the
I have many git repos in different projects and I would like to see a more pigeon view about their developments. I currently just enter individual repos but there must be easier ways. I have used Flow
Is it possible, that a remote branch can have multiple local tracking branches? Or would that confuse the push/pull commands?
I'd like to checkout a branch in such way that subsequent git push will properly push it to origin under same name. This is easy when remote branch already exists git checkout -b branch origin/branch
I'm using netbeans 7.1 and I want to change remote branch to push to. I cannot find a way to do that. If I do a pull, I can see the branches (dev and master). But when I do a push, I only see my local