First, I've been using Git for about 3 days total my entire life. I've read a lot, and I understand the basics a bit.
So we're trying to setup a staging server. The workflow should look like this "local -> staging -> live"
My local machine can connect to the git repo and it sees all the branches, and allows me to push the branches. The live server can see the branches and pull/merge. The staging server was able to clone the master and can see remotes/origin/{and a few other things here}. But the staging server doesn't see all the branches.
I've tried to fetch, I've hard reset, I've setup a tracking branch, and any other thing SO and google have suggested. I have no idea how to proceed here.
This is my output for "branch -a" locally:
$ git branch -a * all-to-staging choose-all country-route master select-to-autocomplete sharebuttons remotes/origin/HEAD -> origin/master remotes/origin/all-to-staging remotes/origin/choose-all remotes/origin/country-route remotes/origin/master remotes/origin/select-to-autocomplete remotes/origin/sharebuttons remotes/origin/tablesaw remotes/origin/wrapping-blockquotes
This is my result on staging:
# git branch -a * master remotes/origin/HEAD -> origin/master remotes/origin/live remotes/origin/master
I can even see the all-to-staging branch:
``
How can I get my staging site to recognize the all-to-staging branch so I can pull it and have people see the change?
So I figured it out, hopefully this might help someone else out later.
using
git remote -v
I realized that my origin was pointing to the live site, and not to my repository.With this knowledge I follwed this guide https://help.github.com/articles/changing-a-remote-s-url/ to change the remote url with the following commands:
SSH is similar, if your repo is private it might be better to do it this way
Check your origins with
git remote -v
, you should see your new origin urlNow there's 2 things to do here, the proper thing, is to make a new directory and Pull your repo down again so that git is basically set up right, that looks like this: cd .. mkdir {new project directory} cd {new project directory} git clone [email protected]:{my username}/{my repo}.git git branch -a git checkout {your branch name} git pull
The second way is trickier because you might run into issues, but sometimes a projects setup is super complicated and it's worth taking the risk before having to set it up again. (This is what I had to do to solve my issue)
Check for branches with
git branch -a
, if you still don't see your branches, then you need to fetchgit fetch
and then you should see your branches, and you can switch to your selected branch withgit checkout
it would look like this: