How can I get git in sync with remote master branch - django

I'm confused about why my production server seems to think it is ahead of my master branch. I use fabric to deploy, and it runs a git pull on the server from my master branch on github. I make no changes that I'm aware of on the production server itself, and I certainly do not make commits on the production server.
git status yields:
# On branch master
# Your branch is ahead of 'github/master' by 57 commits.
#
nothing to commit (working directory clean)
As far as I can tell, what's on the production server matches the master branch on in my dev environment. At least the site acts the same, but I find this disconcerting. Any ideas on how to get the production repository on the same page as github master and stop giving me this message?
Edit (4/11/2013):
Just to clarify, when I use fabric to deploy, it runs:
git pull github master on the server.
My git status results written above in the original question, are on the server. I NEVER make commits on the server, only in my dev environment, which I push to github, which are in turn pulled to the server. That's why I'm confused. I certainly don't want to push anything from my production server to github, that's the opposite direction of my workflow.
2nd Edit (4/11/2013):
here's the fabfile git code:
def prepare_remote_deployment_area():
"""Prepare the production host with updated resources"""
with cd(DEPLOYMENT_ROOT):
run('git pull github master')
this is called from deploy:
def deploy():
"""Deploy an update (committed to GitHub) to production"""
check_git_status()
check_git_status(on_remote=True)
prepare_remote_deployment_area()
restart_uwsgi()
restart_nginx()
restart_celery()
Again, this all seems to work in the sense that the changes I make in my dev environment show up on production. I just don't understand why the production repository thinks it's so far ahead of github master.

Perhaps git pull
git pull origin master
More info
NAME
git-pull - Fetch from and merge with another repository or a local
branch
DESCRIPTION
Incorporates changes from a remote repository into the current
branch. In its default mode, git pull is shorthand for git fetch
followed by git merge FETCH_HEAD.

Related

Vercel - on Pull Request merge to master build promotes to production with preview env variables

On Pull request merge from github triggers Vercel build and promotes merge commit to production. But somehow build contains PREVIEW environment variables like process.env.VERCEL_ENV and feature branch name even Vercel Deployement dashboard shows it is production build on master.
If master gets push without Pull Request - build gets PRODUCTION env variables.
PS. Production branch on Vercel is master.
How to trigger setting env variables as PRODUCTION on merge into master branch?
Or is it a bug in integration with GitHub on Vercle side?

Git commit from a bisect

I have only ever used git add . for this project, but somewhere along the line I started getting the strange "modified content, untracked content" error on one of my subdirectories (called users). Other stackoverflow answers didn't work for me. I used checkout to go back through previous commits, but the buggy/untracked subdirectory didn't change with the rest of the directory. I ended up making manual changes to it and then running git checkout master to make sure everything else was back where it started.
Git is saying that I'm bisecting, and it won't let me commit. I looked over stackoverflow answers, and tried some of the following commands:
git pull:
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
git pull origin master:
fatal: 'origin' does not appear to be a git repository
git branch --set-upstream-to=origin/master master:
error: the requested upstream branch 'origin/master' does not exist
hint:
hint: If you are planning on basing your work on an upstream
hint: branch that already exists at the remote, you may need to
hint: run "git fetch" to retrieve it.
hint:
hint: If you are planning to push out a new local branch that
hint: will track its remote counterpart, you may want to use
hint: "git push -u" to set the upstream config as you push.
git pull --rebase:
There is no tracking information for the current branch.
Please specify which branch you want to rebase against.
Apologies if these commands are all over the place. I intend to really learn how git works soon, but right now I just want to commit the changes so I can deploy my project.
UPDATE: I used git bisect reset, created a new branch out of my detached head, and then merged with the master. This kept the changes I made, so now I just need to figure out how to get users tracked again in my commits. git add users still isn't doing anything.

git pull origin master returns "Already up-to-date" even though it isn't

I'm using git pull origin master to pull my Bitbucket repo onto my Digital Ocean Django server directory (which already has some folders for Django like env and static) . When I do this it says Already up-to-date. but the repo didn't come through? I'm not sure if I'm misinterpreting what git pull does but I assumed it took the contents of mu repo and merged with my current directory. If this isn't true, can somebody explain what other command I should do to achieve this?
Have you set the origin at the first place, from where you want to pull the git repo. If not, then you should set the origin, first.
git remote add origin <link to your git repository>
for eg., git remote add origin https://github.com/gitaccname/gitproject.git
or, git remote add origin git#github.com:gitaccname/gitproject.git
After that, you can pull your git repository into whichever server you like, using the command.
git pull origin master

Git pushing codes From repository 1 To repository 2(collaborator repository)

I need some help because I have some codes that I pulled from my repository branch and changed a couple of things in it.
What I need is to push it into another repository that I have been a collaborator in.
Been trying to push the codes, and trying to access it but to no avail.
Can anybody help me with this one? Any help will be greatly appreciated.
You have two different repositories where you manage to code. First one from where you clone/pull code and made some changes. Second one is what, where you want to push your latest code.
If you clone your repository from GIT then It automatically attach its GIT Url into your application. To check run this command
git remote -v
Result:
origin https://username#github.com/project-name.git (fetch)
origin https://username#github.com/project-name.git (push)
This is url from where you clone/pull your latest code. Now we have created alias of URL as ORIGIN.
so when ever you want to push your code, you will do
git push origin master
Now Add another GIT URL(remote) where you want to push your latest code.
git remote add origin_two https://username-two#github.com/project-name.git
So now commit your changes and made a pull request from your secondary GIT URL this way.
git pull origin_two master
If you got any conflicts then make corrections in code and then again add untracked files using
git add file-name
add a commit message
git commit -m "Your message"
and push your code to git
git push origin_two master
If you are working with branches:
You have two repositories now for a single application. So for that each repo has their own branches, to list down branches for each origin just follow
git branch -a
will list all the branches from two remotes. now If you really want to push on any other branch then you should commit all the changes on current branch an then move to your favorable branch using command
git branch branch-name
and do code here whatever code you will change now push to particular branch
git push origin_two branch-name
That's it :) Hope this can help you.

Unable to push local changes live using Git Push Heroku Master

I'm new to GitHub and have gotten myself into a tangle. I've been successfully deploying code to a Heroku / Django app. However, my last commit was unsuccessful. This is my flow...
- Git add .
- Git commit -m "social media icons"
- Git push heroku master
The last command returns....
Fetching repository, done.
Everything up-to-date
Everything is not up to date. One thing I've discovered on my GitHub app is that I have 2 branches "production" and "master". Master was last updated Sept 8th. I've run a few commands including "git pull origin master" and "git push -f" based on other Stack answers. The latter did seem to push something but not the changes in local. Sorry, I'm trying to find my feet here!
If you're on production branch then you will need to do
git push heroku production:master
Heroku will only deploy the master branch so this command is you pushing your local production branch into the master branch on the remote.
So you are on branch production but your other branch master is up to date. If you want to push the current branch you are on, you should explicitly say so: git push heroku production.
I would highly advise you to try git, it's an excellent resource.