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.
1. Create new repository on GitHub – give 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 init – works fine
2. git add . – works fine
3. git commit -m ‘First commit’ – works fine
3. git remote add origin firstname.lastname@example.org:alfalfastrange/RepositoryName.git – works fine
4. git push -u origin master – I am then treated with a reject message and an error about fastforward etc, etc…
5. git pull origin master – works fine
6. git push -u origin master – the 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 master – Am given message that everything is up to date, I check the online repository and there have been no changes made
4. git pull origin master – Am told everything already up to date
5. git push -u origin master – Am given message that everything is up to date, I check the online repository and there have been no changes made
6. git push origin master – Am 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
After running steps 1 – 6 with the -f added to step 3
After running sequence of commands from answer
Which doesn’t make any sense to me because we did all that already… I’m using only the Git Bash
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:
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
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
That would mean git branch would show no current branch (with ‘
*‘ in front of it).
Other causes: “git says Everything up-to-date”.