. Advertisement .
..3..
. Advertisement .
..4..
I have the following git code, but I do not know how to find the correct result. Why has this problem occurred, and how can it be solved? Here is the code that I am running:
git add <file1>
git add <file2>
git commit
git status
And this is the error text I receive:
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
#
nothing to commit (working directory clean)
The cause: The cause of this error is that one commit in your local repository hasn’t been pushed yet.
The solution: The following is the sequence of solutions:
git add
– this stages your changes for committinggit commit
– this commits your staged changes locallygit push
– this pushes your committed changes to a removeNothing gets pushed if you push without committing. Nothing is committed if you commit without adding. When you add without committing, nothing happens; git simply remembers that the modifications you made should be taken into account in the next commit.
git reset HEAD^ --soft
(Save your modifications, go back to the last commit)git reset HEAD^ --hard
(Discard any changes and go back to the last commit).