Git: Changing to a Remote Branch From a Clone
I've got a git workflow question, and I don't fully understand all the terms to know what to google for.
The short version: Is it possible to "switch" your local git directory to a branch from a remote repository, when your local repositories started as clones of the remote repository? I'm newish to git, so I'm still coming up to speed on the terminology here; if I've said something that seems off/wrong/making-an-assumption please let me know.
The long version.
I have a local repository that's a clone of "the central" repository. This repository has several branches, each of which is many revisions ahead of the original repository's master branch.
$ git branch
I know I can "switch" to one of my local branches by using git's
$ git checkout foo
$ git checkout universal_imports
I also have a few remotes
$ git remote
upsteam's master branch is our source of truth. It is the product, the aforementioned central repository. As previously stated, my local master repository started as a clone of this repository. (actually, my local repository is a clone of the
origin remote, which is a github fork of the upstream's master branch. I'm unsure if that's relevant)
Here's the scenario I'm trying to solve. I've been doing new development on my branches. I'm many versions ahead of the original master. However, I've just received a request to fix something in production. My mental model here would be to
- Switch my local code so it matches the production code
- Do the fix and commit it
- Merge my local code into the source-of-truth branch
- Switch my local code back to my "real" branches, and continue new feature development
The goal is to avoid putting any of my new code into production before it's ready.
Short of re-cloning the central repository somewhere, is there a git workflow for this? Ideally I'd like something like i described "switch to a remote branch", but if that's nonsense talk is there a way I could have worked with git that would have allowed me to handle this situation. (blaze ahead on new work, but main the ability to work off a point further back in the history)
I recently started using the GIT command line commands ( I used to use SourceTree). When I want to create a new branch, I would usually do git checkout -b <branch-name>. When I want to push it t
My remote Git repository has 3 branches: master develop news When a dev change he will branch off develop such as issue123. When he finished changing, he will push to remote issue123. I will merge
I have checked out a svn repository using git svn. Now I need to checkout one of the branches and track it. Which is the best way to do it?
Is there a simple way to export a single file from different git branch (local or remote) without checking out that branch?
I am using EGit 2.1.0 in eclipse juno. On a repository I right-click the origin/master branch in the Remote Tracking folder and create a new branch: Source ref: refs/remotes/origin/master Branch name:
Not understanding why my commit to remote git repo is not working. So I clone a branch from the remote repo git clone -b MYBRANCH firstname.lastname@example.org:/home/my.git I modify a file called test git diff sh
Is there a way in git bare repository to push a branch that is not in HEAD right now? For example i have two branches: $ git branch * master another And i have two remotes set: origin and another. I
I want to add a remote, and a branch of that remote. I did git remote add <newname> <url>, then I did git fetch --all but git branch -a is not showing any branch of the remote. My .git/con
I'm pruning some branches off of a git remote. How can I find out who created a branch on a remote git repository? Maybe there is something similar to git branch -r --show-user?
I'm new to git and github and i have a question about the git plugin for eclipse Egit. I have made a clone from my github repository to a remote server (other than github) which i will call 'rserver'
all I have downloaded source code from google android website following google's guide. My purpose is to create a local branch to track remote branch take framework/media for example, you can see .git
I've cloned repository A's master branch from git and created my own branch called Li. I've made some changes a while ago and pushed the contents of local Li to remote Li. Now I've pulled some updates
Is it possible to clone only one branch (or from a given commit) in Git and Mercurial? I mean, I want to clone a central repo but since it's huge I'd like to only get part of it and still be able to c
Problem: Need to push the changes from local git branch to a different remote git repository branch and this changes pushed to the branch will be compared with the master existing in the remote URL an
i checked out a remote branch like git checkout -b newBranch origin/some-remote-branch. but whenever i do a push it is pushed to a new branch newBranch . how to tell git to automatically push to the b
I was working on a feature (on my local master branch), git status showed me that I have 3 modified files uncommitted. That's ok. Then I noticed a bug on the live site. I wanted to abandon my current
Is there a way to clone a git project with more than one remote repos? For example, in addition to origin, I would like to have a few other remote repos to push and fetch the data. Is it possible to
I'm trying to clone a project that is remotly located to my local machine. So: 1) I navigate to the local folder where I want to have my files. 2) I connect to ssh on the remote machine: ssh something
I am trying to automate my interactions with Git building a script and I am having the following problem. This works from the command line: git clone email@example.com:blablabla/reponame.git /Users/
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 want to create a local and a remote branch named test from the develop branch on origin. However, even though my current local branch is tracking origin/develop when I checkout the new branch it tak
I'm using GitHub, when I git branch -a, it shows like this: master * develop remotes/origin/HEAD remotes/origin/develop remotes/origin/master remotes/origin/feature001 remotes/origin/feature002 remot
I know there are questions floating around regarding git pull from a specific branch when you provide no explicit branch name, however I am wondering if it's possible to force a pull branch even if th
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
When trying to delete a remote branch I get the following error: $ git push work :18300-018_5 remote: Processing changes: refs: 1, done ! [remote rejected] 18300-018_5 (can not delete references) erro
I'm working on one of the cakephp website, where i use git as a version controller. I have 2 types of different branches are there : 1) development 2) ui When i try to push my latest changes from dev
I am trying to clone remote git repository with Egit, via https protocol. I followed this online tutorial. When I insert URI: https://username@host:port/repositorypath, password and click NEXT, I am g
I am trying to clone git repo of vlc media player from git.videolan.org, but its failing even though I tried some tips mentioned in similar questions on SO Getting following errors while trying to cl
I am wanting to bring a newly added remote branch into my local repository without interfering with my local branches. Is this possible? When I do: git branch -a The new remote branch doesn't appear
I was working on a small update on the master branch, which quickly evolved into the new version of the app. However, I wasn't tidy enough to create a new branch from the beginning, so now I'm stuck b
I have cloned a project from Github from branch, say, br1 git clone --branch br1 https://www.github.com/project/project /opt/project/ I would like to switch to branch br2 as if I had did this from th
I am almost newby in Git and just read Git book from the official site. I try understand difference between next cases. git init Project git remote add Project [some-url] and git clone [some-url] A
I would like to 'git clone' from a remote repository with boilerplate code, but treat it as new repository created via 'git init', meaning I don't want it to have remote/origin and any commit history.
I already googled, and read many document. but Unfortunately I cannot understand them all My situation is. git branch -r origin/HEAD -> origin/master origin/master origin/team/myteam git branch -a
I'm trying to clone a git repository from a certain date. Even if this is not possible. Is it possible to clone the git repository and then roll it back to a certain date? Example: my repository has b
I have the following remotes set up: $ git remote korg rorg And the following branches: $ git branch -a * (no branch) remotes/korg/gingerbread remotes/korg/gingerbread-release remotes/korg/honeycomb
I need to recover two Git branches that I somehow deleted during a push. These two branches were created on a different system and then pushed to my shared (github) repository. On my system, I (appa
There are a few things I don't understand about the output of git clone. In the following example : Cloning into 'omap-kernel'... remote: Counting objects: 2649896, done. remote: Compressing objects:
I have two branches: local branch (the one which I work with) remote branch (public, only well-tested commits go there) Recently I seriously messed up my local branch (guess every git-newbie has bee
Is it possible to clone a git repository from github without the full URL? For example: When I have to run this: git clone https://github.com/foo/bar.git I want enter this: git clone foo/bar I saw a s
I am trying to close a git reposotory into my netbeans. I did Team->Git->clone I set the repository url and all , push next , and than there are no branches to select from. How do i add a branch
I'm using git as an interface to an SVN repository. Now I've created a SVN branch: git svn branch my_branch This created the directory in my SVN repository, and also created a branch called remotes/m
I'm new to Git. Starting work on any project seems to start with a git clone. But this seems to take a long time - much longer than the equivalent svn checkout. Is this because the entire history
When I try to perform the following command, git clone git://github.com/mainDir/dirA, I get the following error: > git clone git://github.com/mainDir/dirA Cloning into 'dirA'... fatal: remote error
As far as I understand these two commands can remove remote-tracking branches. Is there any difference between them? git remote prune <branch_name> git branch -d -r <branch_name>
I've started work with a messy repository: the task is to remove all useless, merged-in branches. When I list the remote branches, I can see: remotes/origin/xx12 remotes/origin/xx13 remotes/origin/rem
I would like to clone a branch, make a change and push into the same branch. I'm doing this: mkdir myfolder cd myfolder git init git clone myurl -b mybranch git remote add origin myurl edit myf
I'm having trouble comparing local master (which is on same commit as origin/master) with production/master. $ git remote -v origin firstname.lastname@example.org:mydomain/mydomain.git (fetch) origin email@example.com:m
Is there a way to clone a remote git repo while keeping any unreachable commits that may be in that repo? The scenario is this: I need to recover a branch that was deleted from a bare git repo on a se
Is it possible to clone a project into a new branch ? I have already cloned the main repo and would like to clone another repo that is a fork of it into a branch. I want to be able to keep comparing t