Reputation: 17461
I have a project which have to many redundant code that have to be removed.
What Git operations I have to make, so it still be easy to look removed source and also to be easy to return it in project if I need to?
Do I have to make any branches? Tags? Or just delete files from my master branch?
My project is hosted in GitHub if this information is helpful :)
Upvotes: 2
Views: 475
Reputation: 16197
Just remove the code in a meaningful way (small, atomic commits).
Then use a graphical interface to git to look at a file's history. On Linux I always use QGit ( http://sourceforge.net/projects/qgit/) but there are also Windows and Mac programs as well as online browsers (even Github does it but not too well).
This is what I regularly do. In your case you could create a tag to later aid you to find the right time in history.
Returning the code is then also easy. Simply copy and paste it.
Upvotes: 0
Reputation: 19940
I do such refactors by
git merge --no-ff --no-commit Workbranch
The --no-ff
parameter causes git to create a 2way merge even when it could do a fast forward merge, the --no-commit
gives you the possibility to change the commit message.
When you need the current state, you can create a tag to create a symbolic name, so you can refer the current state by this name.
Upvotes: 0
Reputation: 11307
I would be tempted to just remove the code in one or more commits in the master branch (I'm assuming you don't have a lot of developers and there is no need for an advanced workflow). Then you can cherry-pick
or revert
the commits if you want the code back or use git show
to see the deleted code.
Upvotes: 1
Reputation: 30167
Just delete it from master branch, you can always look back in history.
-- edit --
Returning it back might be trickier though. What you can do then is branch current code off, push the branch to github and remove from master then. In that case it should be easier to cherry-pick the code you removed later on.
Do note, however, git is not a file-based tracker, so easiness of code recovery will solely depend on how well you used the concept of atomic commits.
Upvotes: 2