开发者

git - changing versions of code?

开发者 https://www.devze.com 2023-02-23 03:35 出处:网络
Right now my method of using git is to develop a website locally and when it\'s looking good, to git push origin master and then ssh into the server and git pull origin master. I\'m curious if there\'

Right now my method of using git is to develop a website locally and when it's looking good, to git push origin master and then ssh into the server and git pull origin master. I'm curious if there's a way to easily change versions of an app. So say I开发者_JAVA百科've added a couple features and then want to remove them for a little while. How could I go back without just removing the code?


You can use git checkout X, where X is a tag name, or a commit ID. To see the commit you want to go back to, you can use git log.

(Beware, this will put you in a detached HEAD, so don't do any commits until you used git checkout master to go on top of the master branch again.)


Add the features on a branch, then pull that branch from the server. When you want to revert to the trunk just do that. When the features are ready, merge the branch into the trunk.


So long as you have been versioning the files in question, I think what you are talking about has been covered here - Rollback file to much earlier version using Git

and here - Reset or revert a specific file to a specific revision using Git?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号