Take arbitrary git working copy and make exactly the same as remote branch
Say I have an arbitrary local git working directory that was cloned from some remote. I want to make the local git repository be EXACTLY the same as the remote, irrespective of what's happened to the local directory since it was cloned. I do not want to do another full clone.
Say the local working directory has:
- additional untracked files
- deleted files
- staged changes.
- may be on some arbitrary branch.
- have a bunch of commits since being cloned from remote
Now I want to make this local repository reflect remote exactly. Here's my current solution but I'm not sure if it covers all cases and whether there is an easier solution:
git clean -f -x -d
git checkout master
git fetch origin
git reset --hard origin/master
git pull origin master
Is there a better way to do this?
This question already has an answer here: Make an existing Git branch track a remote branch? 10 answers I created a new local branch and pushed it with git push origin my-branch How can I auto
I've checked the remote branch Design0.5: the last remote commit on that branch is identical to the top local commit, here marked (no branch). So locally, Design0.5 is 5 commits behind where I'd like
So on Computer A, I did the following. git branch test git push On a different machine Computer B, I pull the changes and track the remote branch test git pull --all git checkout -t origin/test all
When I perform branch -a: $ git branch -a * master remotes/origin/HEAD -> origin/master remotes/origin/hello remotes/origin/master And then I remove the branch: $ git branch -r -D origin/hello Del
Is there a git command or combination of commands that tells me if a working copy is behind its remote in a strictly read-only way? I'm looking for something that works without errors if the working c
I have forgot to create local branch and was working with remote. After making some changes, i by mistake using Eclipse Git plugin commit this branch in nowhere(obliviously there wasn't local branch).
Reset local git repo to exactly that of remote? What is the best way to do this? Thanks!
I made a git branch unintentionally named 0.2 which is also a tag. So I tried to remove it from origin: $ git branch -rD origin/0.2 Deleted remote branch origin/0.2 But then: $ git fetch origin * [
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 just started using git, I am faced with a situation where I have two remote branches master and alpha. Each branch has 268 packages. Now I have to copy everything from branch master which had a lot
I am working on a project with a remote team. They created a branch (r_branch) that I can see when I'm in GitHub: master r_branch (and it tells me that it's 6 ahead) When I do git branch -r, here's w
Let say I'm on the road with a friend, we are offline from the bare git repository. I have a working copy (with .git folder) and my friend want to help me out so he clone my git repository from my wor
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) $
Here's the scenario. I have a series of commits in branch my_new_branch I want to push this branch up to the remote repo as a different name and track it. If I do: git push origin my_new_branch:differ
I cloned an existing svn repo off a remote server locally using git-svn's git svn clone <orig_svn_repo_path>. I now want to setup a remote repo for only a particular branch out of several branch
master branch has these files and folders (simplified): C:\Local\TickZoom\Project>ls file.txt name.txt public public branch is tracking a vendor repository and has been subtree merged as public fo
I am on a repo on github. I have one local branch called : master and on the remote repo there are two branches, branch1 and branch2. I cloned the repo from the branch1. But then, I wanted to pull bra
I'm working on a remote branch named sidebar, created like this (from my pc, not remote repo) : $ git branch sidebar $ git checkout sidebar $ git push -u origin sidebar $ git pull origin sidebar Afte
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 remot
git checkout master git archive stage | tar -czf archive.tar.gz htdocs # archives master because it's checked out. How can I archives the stage branch, regardless of the current I'm on?
According to GitGuys Remote Tracking Branches should not be modified by users (don’t set your git branch to a remote tracking branch via git checkout and then try to modify the remote tracking branch
I have created a remote branch, that I now want to delete because it is merged back into our integration branch. I do a git push origin :name_of_branch to delete the remote branch. However, unfortuna
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
I've accidentally unhitched my master branch from tracking origin master I think. It used to be that I could run git pull and git push and it would know that I meant git push origin master but now it
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 -
Possible Duplicates: How do I push amended commit to the remote git repo? Undoing a git push Hi, I've deleted some commits from my master branch by using git reset --hard SHA_VALUE I have, however
I'm a little confused about git fetch and comparing differences . I have the following local branches; master remote/origin/master In master branch I have a text file which I make changes to, comm
If I create branches on my local git repos like so: git checkout -b test then do a push git push I don't actually see the new branch test in my GitHub page. How do I make my remote branches mirror my
When git clone some repository then it retrieves all branches from it: git clone https://github.com/android/platform_build.git build1 cd build1/ && git branch -a && cd .. then, when I
I want to know if there is a way on the git command line to copy the branch history from a remote repo. In other words, I want to copy the .git/logs directory from the remote to my .git/logs directory
Added a new Branch to my Github, but can't find a way to have my local repo know about it. I have my local repo using the master branch (the only one it knows about), and it is several commits ahead
I have created a local branch X that at some point I pushed to remote server (origin) git push origin X I realized it's a bad idea to have branch named X and want it to be called Y The problem is tha
Is there a way to set up a git repository, so that git pull defaults to one remote and git push defaults to another? I know I can set both by changing the value of the remote variable in branch sectio
I want to switch to the remote branch in Git. What is the difference these commands? git checkout -b feature1 origin/feature1 and git checkout --track origin/feature1
I find it little confusing to know the difference between git branch --set-upstream-to vs git remote add origin or even git remote add upstream Basically I have a bare repository created with git init
Is there any way to reset a remote branch pointer to a SHA that you know is in the remote reflog, but that you don't have in your local repo? I'm very familiar with how reset (soft/mixed/hard) works o
I have one problem, I have been reading about that but I am not sure which solution is correct and as of now I am unable to test which solution is the right one. So, I am working on a remote branch, c
I want git to forget everything that I have edited in local branch, and want to pull the update from remote branch. I did not know how to do that and I am getting merge conflicts on few files. What
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
First post on SO so please forgive me if I miss something. I'm new to git and am loving it. Things have been mostly going smoothly with the exception of this.. Developers I'm working with pushed a new
I've been reading Pro Git, and I think I get how things should be done. But I might have made some weird adjustments in my ignorence before, maybe egit made incomplete changes to the repo one of the t
git push origin master Total 0 (delta 0), reused 0 (delta 0) error: unable to resolve reference refs/heads/master: Permission denied remote: error: failed to lock refs/heads/master To git@remote-repo
How can I make git issue a warning to me if I am on branch x and trying to pull from branch y? To give an example; Consider that my current local working branch is x and I am issuing: git pull ori
I have a vanilla git installation with default configuration, version 1.7.1. So I do the following actions: git branch local_only git checkout local_only git push local_only does not exist on remote.
It'd be awesome if someone helped me get this. Say I'm working in master or in a branch called MyBranch and I want to push the changes I just committed to a new github branch. When I do git push origi
This question already has an answer here: Git push error '[remote rejected] master -> master (branch is currently checked out)' 23 answers WHAT I AM TRYING TO ACHIEVE--- I know little about
After messing up with my git branches a lot, I ended up with a stable develop branch and unstable master. I merged my stable commit of develop branch into master. But still my master is unstable. How
I'm using the Pages feature of GitHub. This works by putting the published HTML in a branch called gh-pages. I have two separate working directories, one for the project itself and one for the HTML do
According to Pro Git (3.5): [remote branches are] local branches that you can’t move; they’re moved automatically whenever you do any network communication. However, this doesn't seem to be correct i
I recently forked a project and stuck to an issue. I have following remote: $ git remote -v origin email@example.com:Hesamedin/passenger-android.git (fetch) origin firstname.lastname@example.org:Hesamedin/passenger-andr