Back

Explore Courses Blog Tutorials Interview Questions
+2 votes
3 views
in DevOps and Agile by (29.3k points)

I found many questions with a similar subject, but I didn't found any practical guidance about this issue: why git status informs me nothing to commit, working directory clean, even though I have made a modification at my local branch?

Here are the steps which I followed:

git init 

git remote add https://github.com/username/project.git

git pull origin master

touch test

git add test

git commit -m "Adding file for test purposes only."

git status [On branch master - nothing to commit, working directory clean]

If I do a git push, the modification is committed to the remote branch. I just want to perform "git status" after my modifications, and receive the information that I have changes on my local branch that must be pushed to the remote branch of the project.

Can someone tell me what's going? Straight to the point, please.

1 Answer

+2 votes
by (19.4k points)
edited by

Your local branch doesn't know about the remote branch. so that you need to tell git that your local branch is supposed to compare itself to the remote (origin/master in this case); To see the difference you should use:

git branch --set-upstream-to origin/master

or with the short option:

git branch -u origin/master

This options --set-upstream-to (or -u in short) was introduced in git 1.8.0.

Once you have set this option; git status will show you something like:

# Your branch is ahead of 'origin/master' by 1 commit.

To learn more about Git and Git commands, you can visit Git Tutorial.

You can watch this Git Tutorial video for more information:

Browse Categories

...