Jump to content

Recommended Posts

I'm new to get and am trying to understand how to effectively use it. I have a few questions. Say you're starting a project from scratch working with a php mvc framework. How often and when should you commit/push? every time you write a function? every time you finish a file(for now)?

 

So commits are labeled with SHA1 hashes, can you take the hash of any commit and use some git voodoo to rebase a specific file to that commit? or does it work more like rebasing your whole branch at a certain point in time(commit)?

Link to comment
https://forums.phpfreaks.com/topic/240710-anybody-use-git/
Share on other sites

For me I commit every time i finish a feature, it passes all the tests and is stable or before i start working on a new feature (these two are usually the same but not always). Also you can revert file to the state that it was in at a commit. another useful thing about git(or any source code control) is that you can use sites like github to make team coding easier.

Link to comment
https://forums.phpfreaks.com/topic/240710-anybody-use-git/#findComment-1237099
Share on other sites

Group changes into commits that are relevant, part of the same change or at a point where it would make sense. If you write your entire application and then commit, you loose the ability to rewind back to previous states during the development process. If you commit too often, well there's not really a massive down-side to this, but you'll waste plenty of time doing so. It's a good idea to commit fairly regularly though, to make the most of Git's features.

 

"can you take the hash of any commit and use some git voodoo to rebase a specific file to that commit?"

 

You can checkout a single file at a particular commit with:

 

git checkout <commit> <file>

 

Then to go back to the current (HEAD) commit:

 

git checkout HEAD <file>

 

Or you can use reset to reset all files (any changes you've made, staged or not, will be lost) back to the state they're in at HEAD:

 

git reset --hard HEAD

 

You can rebase a whole branch onto another specified commit, merge another branch, cherry-pick commits on to your branch, etc, etc. Git has a lot of powerful features, it just takes time to pick them up.

Link to comment
https://forums.phpfreaks.com/topic/240710-anybody-use-git/#findComment-1238248
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.