문제

I am trying to understand how version control works in git/github. I can clone, pull, merge or add and remove remotes. What I don't understand is how to separate versions.

Here is an example. Suppose I have a entire site stored in github.com/user/foobar_site Now, assume I have completely remade my local copy of foobar_site, but I don't want to push this and have it get mixed with my remote copy. So, what I would like is to keep my remote intact and push my local to it without mixing the two. The end result would be, I will be able to git clone the first version of foobar_site and the second version at any time.

Is such thing possible? if so, then how?

도움이 되었습니까?

해결책

git push doesn't mix (merge in git-speak) anything. It takes your local copy, and tells the remote side that this is now the current version. The old version will still be available using its commit ID, or you can create a tag or branch to refer to it.

git log will show you all previous versions of your repo.

git commit -m "Old stuff"

(change loads of files)

git commit -m "New changes"

git log --oneline

10a3fe2 New changes
7f0ceaa Old stuff

You can get back to any old committed version of your code with git checkout:

git checkout 7f0ceaa

And back to the current version with

git checkout master
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top