Prashin Jeevaganth
Prashin Jeevaganth

Reputation: 1363

What are the git commands that can help me in this situation?

I am new to git. I face this problem of having to add new features to my application on github and the dilemma of when to push and how to retrieve the entire version of code as I needed.

I have the habit of just cloning my repository, v0 and editing it locally on my computer, call this directory_v1. Then I would edit directory_v1 , and there might be a time my changes don’t seem to be working and I would want to revert back to v0(like re-clone again and start from scratch), and I don’t think it would be wise to push the failed plan into origin as that would prevent me from getting v0 back.

While I might revert back to v0 at some point, I still want to track my progress on directory_v1, like commit my changes. If I’m not wrong, commits are not “saved” if you don’t push, but the problem is if I pushed, I do not know how to retrieve the entire directory out of that commit timestamp and “clone” it locally to my computer.

I know of a command that might do something similar. git checkout commit_id, but from what I know from tutorials, I only see people taking out 1 file out of the entire branch, instead of the “clone whole version into directory” idea, and that requires me to know exactly what file I needed in my development process, and my previous commits were actually “pushed”. However, I’m not that professional at my current level, and would definitely prefer to work in a local directory where I could view in column view and work with the files neatly(since implementation usually requires many changes simultaneously).

Can anyone help me with this?

Upvotes: 0

Views: 51

Answers (1)

VonC
VonC

Reputation: 1329082

The actual command is git checkout -b|-B <new_branch> [<start point>]:

git checkout -b newBranch old_commit

That way, you don't need folders, you can develop in a separate branch.

To see those branches in action, follow the tutorial at learngitbranching.js.org

Upvotes: 2

Related Questions