Still learning git - what does "Changes not staged for commit" mean?

Ed September 30, 2016

I just completed the following:

git add * && git commit -m "message" && git push

However, sometimes I see this issue and am confused as to what it means. Sometimes it's for files I delete and sometimes it's for changes that have not merged correctly.

 

On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)

deleted: gitup.sh

no changes added to commit (use "git add" and/or "git commit -a")

2 answers

0 votes
DrSnigglypoof
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 30, 2016

Quoted from this site: https://www.atlassian.com/git/tutorials/saving-changes/git-add

"The staging area is one of Git's more unique features, and it can take some time to wrap your head around it if you’re coming from an SVN (or even a Mercurial) background. It helps to think of it as a buffer between the working directory and the project history.

Instead of committing all of the changes you've made since the last commit, the stage lets you group related changes into highly focused snapshots before actually committing it to the project history. This means you can make all sorts of edits to unrelated files, then go back and split them up into logical commits by adding related changes to the stage and commit them piece-by-piece. As in any revision control system, it’s important to create atomic commits so that it’s easy to track down bugs and revert changes with minimal impact on the rest of the project."

So when you make a change to a file in git. The first command: git add

 

Places the saved change in the staging area where you can combine several changes into a single commit which saves those changes to the project history. 
For example: 
I make a change to myquote2.html in my documentation-tests repository. I haven't done anything but make the change yet and if I run git status I can see this: 
image2016-9-30 15:45:24.png
Which indicates that the myquote2.html file has changed but those changes have not beed added to the staging area. 
Now I run git add myquote2.html to add the file to the staging area. Then I run git status again (you really don't have to do that every time but for the sake of illustration) and I see this: 
image2016-9-30 15:48:13.png

Now you can see myquote2.html is in the "Changes to be committed" section which is the staging area. 

Then I run git commit myquote2.html -m 'repeated quote to show how a change moves through the process' which commits the change to the project history.  

image2016-9-30 15:51:20.png

Now you can see the file is committed (um, to master in this case which is generally NOT a good idea wink ) and the working directory (your local folder) is clean. 

Hope this helps a little. We've got some pretty good tutorials for git and Bitbucket: 

https://www.atlassian.com/git/tutorials/learn-git-with-bitbucket-cloud

To learn pull requests:

https://www.atlassian.com/git/tutorials/learn-about-code-review-in-bitbucket-cloud

Or how to use SourceTree if you prefer an app to the command line:

https://confluence.atlassian.com/display/BITBUCKET/Tutorial%3A+Learn+SourceTree+with+Bitbucket+Cloud

 

Happy coding,

Dan

0 votes
Seth
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 30, 2016

The git book is a great resource for learning the basics. Here's the page that explains what "staging" is: https://git-scm.com/book/en/v2/Git-Basics-Recording-Changes-to-the-Repository

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events