Stash the very first commit on an empty project repo
I am new to git and try to understand how I ll undo /stash changes + logs lets say I have a very fresh branch with no commits yet e.g
git clone https://url testrepo cd testrepo git log fatal: bad default revision 'HEAD' git checkout fatal: You are on a branch yet to be born echo "test" > README.txt git status On branch master Initial commit Untracked files: (use "git add <file>..." to include in what will be committed) README.txt nothing added to commit but untracked files present (use "git add" to track) git add . git status On branch master Initial commit Changes to be committed: (use "git rm --cached <file>..." to unstage) new file: README.txt git commit -m "My read me file " [master (root-commit) 6357fd2] My read me file 1 file changed, 1 insertion(+) create mode 100644 README.txt git status On branch master Your branch is based on 'origin/master', but the upstream is gone. (use "git branch --unset-upstream" to fixup) nothing to commit, working directory clean
(I don't understand what does "upstream is gone" mean :( )
However, now lets say I want to stash all changes. One simple solution is to delete the clone and re-clone from remote repo . What are other options to undo the above commit so I ll again have a clean checkout (without commits + commit history (logs)
You have created a project and added some content to it. Since you have clone an empty repository it does not have any content yet.
fatal: bad default revision 'HEAD'
To understand what HEAD is - read about in here: How to move HEAD back to a previous location? (Detached head)
I don't understand what does "upstream is gone" mean :(
Since you have cloned an empty repository there is no such branch named master on the remote so you have to create it (end of the answer).
If you would have cloned an existing repo you would have gotten the master branch (or any other default branch) checkout out to your project.
In your case as explained above you have cloned an empty project so you have to first push master
git push origin master
Why do i need to push the master branch?
The first commit to your local repository created master branch and it still not found on the remote.
However, now lets say I want to stash all changes.... What are other options to undo the above commit so I ll again have a clean checkout
Read the above linked post about head to learn how to do it.
Another option is to checkout an orphan branch (branch without any history)
git checkout --orphan <new_branch>
And you will have a clean branch with the content of the folder but without any history.