L
L
learnfrontend2016-11-19 11:58:06
git
learnfrontend, 2016-11-19 11:58:06

How to roll back to the very first commit?

How do I roll back to the very first commit without copying its hash.
You clone the repository and there +100500 commits and scroll to the very first one in the console to copy its hash - not a cake. Is there such a universal command?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
rPman, 2016-11-19
@rPman

and the religion does not allow saving in the log file?
in essence, redirect the output to tail and specify the -n N switch, as a result you will get the last N commits
git log --pretty=oneline | tail -n 1

R
Roman Mirilaczvili, 2016-11-19
@2ord

Old repository:
Copy to buffer the URL in the fetch line
Create a new repository:

git init
git remote add scratch <remote-github-url>
git fetch scratch
git cherry-pick <FIRST-COMMIT-SHA1>
git remote remove scratch (опционально)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question