Changes to VS2010 solution won't commit to GitHub repository

I’ve been having a hard time with Git since I started using it. It’s a learning curve that I want to beat. I’ve read thru the manuals and FAQs and several other sites but I’m still not seeing the behavior that I expect and hoping someone that’s using VS2010 with GiHub can’t give me the magic pointer I need.

These are the steps that I do to create a new project/repository.

  • While building a git project from jenkins it shows an error like couldn't find any revision to build
  • Adding a historical directory to Git branch
  • Can't exclude a folder using .gitignore
  • How to record a history of releases for a web project in Git?
  • Git repo still huge after large files removed from repository history
  • Git apply patch fails silently (no errors but nothing happens)
  • 1. Create new repository on GitHubgive it a name and create it

    2. Create my solution in VS2010

    3. Commit for first time

    These are the steps that I take to commit the solution for the first time:
    (I have git and git extensions installed and I have a VS Toolbar created that allows me to pop up the git bash from within VS2010)

    I click on the Git Console button I have created on the toolbar and I get the bash window and the current directory is the root directory of my solution

    I then execute these commands to commit my solution to the GitHub repository on the GitHub site

    1. git initworks fine

    2. git add .works fine

    3. git commit -m ‘First commit’works fine

    3. git remote add origin fine

    4. git push -u origin masterI am then treated with a reject message and an error about fastforward etc, etc…

    5. git pull origin masterworks fine

    6. git push -u origin masterthe commit works and I can then see the whole solution online on GitHub

    Now the problem I have is from here on out… if I make and changes to my solution I cannot get them into GitHub. For example, I delete files, add files and add code, etc and then I’m ready to commit all these changes

    I’ve tried these sequences of events and had no luck

    1. git add .

    2. git commit -m ‘Second commit’adds changes to the local repository

    3. git push -u origin masterAm given message that everything is up to date, I check the online repository and there have been no changes made

    4. git pull origin masterAm told everything already up to date

    5. git push -u origin masterAm given message that everything is up to date, I check the online repository and there have been no changes made

    6. git push origin masterAm given message that everything is up to date, I check the online repository and there have been no changes made

    It seems all the commit does from that point on is commit changes to the local repository and none of the commands I’ve tried will push the changes to the GitHub repository.

    So at this point I’m slightly annoyed that it’s not easier. With my Ankh SVN and Codesion setup all I have to do is click Commit or Update to push changes or pull latest from the online repository.

    What am I missing? Because I want to be able to use Git successfully and without fear for all of my personal projects. Thanks in advance!


    After running the git branch -avv command this is the result

    enter image description here

    Update 2

    After running steps 1 – 6 with the -f added to step 3

    enter image description here

    Update 3

    After running sequence of commands from answer

    enter image description here

    Which doesn’t make any sense to me because we did all that already… I’m using only the Git Bash

  • Are there any bad side effects by ignoring .gitignore?
  • git cloning gnome core suite
  • Customize gitk for each repository
  • Is there any IDE/GUI support for git-flow on Windows/Linux?
  • Huge TYPO3 project with CI workflow and single feature deployment
  • How does git track file changes internally?
  • 2 Solutions collect form web for “Changes to VS2010 solution won't commit to GitHub repository”

    Just so people don’t have to scroll through the comments:

    Run git fetch origin to fetch the remote branches into your local repository. (You could also roll this step into the git remote add step with the -f flag.) Once that’s done, you can track the remote master with your local master.

    Once everything is hooked up, the simplest workflow looks like this:

    # assuming an up-to-date branch and a dirty working copy
    git add .   # Add changes under the current directory to the index
    git commit -m "Commit message"
    git push origin

    You can roll the add and commit into one step as well:

    git commit -am "Commit message" # Commit changes in tracked files to your local repo

    Keep in mind I have no idea how Gitextensions works; it probably has its own plugin-y stuff for this.

    Your first error message was certainly:

    $ git push origin master
    To ../remote/
     ! [rejected]        master -> master (non-fast forward)
    error: failed to push some refs to '../remote/'

    Which is normal, considering you had two parallel history going on: the one of GitHub (empty repo) and the one in your local repo. See also “I am not able to push on git?”
    Once you you git pull, you merge the initial history of GitHub in your local repo, and make your first push successfully.

    Now if the next git push (no need to add -u again by the way) reports that everything is up to date, check if you are not in a detached HEAD mode.
    That would mean git branch would show no current branch (with ‘*‘ in front of it).
    Other causes: “git says Everything up-to-date”.

    Git Baby is a git and github fan, let's start git clone.