2011-06-30 5 views
10

Mon journal git montre quelque chose comme:Comment extraire une version particulière dans git de git log?

enter code here 
[git_trial]$ git log 
commit 4c5bc66ae50780cf8dcaf032da98422aea6e2cf7 
Author: king <[email protected]> 
Date: Thu Jun 30 15:09:55 2011 +0530 


This is third commit 

commit 8072be67ddd310bc200cab0dccb8bcb2ec4f922c 

Author: king <[email protected]> 

Date: Thu Jun 30 14:17:27 2011 +0530 

This is the second commit 

commit 3ba6ce43d500b12f64368b2c27f35211cf189b68 

Author: king <[email protected]> 

Date: Thu Jun 30 14:00:01 2011 +0530 


This is the first git commit for file1 

Question 1) Maintenant, comment la commande que ma première version? Question 2) Aussi quand je le fais, git se connecter uniquement sur File1, pourquoi ne montre-t-il que le premier commit?

[git_trial]$ git checkout 3ba6ce43d500b12f64368b2c27f35211cf189b68 
Note: moving to "3ba6ce43d500b12f64368b2c27f35211cf189b68" which isn't a local branch 
If you want to create a new branch from this checkout, you may do so 
(now or later) by using -b with the checkout command again. Example: 

    git checkout -b <new_branch_name> 


    [git_trial]$ git log File1 

    commit 3ba6ce43d500b12f64368b2c27f35211cf189b68 

    Author: king <[email protected]> 
    Date: Thu Jun 30 14:00:01 2011 +0530 

    This is the first git commit for file1 

Répondre

28

Vous pouvez extrayez une commettras utilisant git checkout sha-of-commit que vous avez déjà.

Mais vous ne pouvez rien valider (comme vous n'êtes pas dans une branche, vous êtes dans un commit statique).

Si vous devez valider quelque chose au-dessus de cette validation, vous devez l'extraire dans une branche à l'aide de git checkout sha-of-commit -b testing-a-commit.

git log <file> affiche uniquement les validations qui affectent ce fichier.

+0

Désolé pour la réponse tardive ... net est trop lent ici. Donc, vous voulez dire, si je crée une branche, puis faire mon premier et successifs commits, alors je peux commander une version particulière? – kingsmasher1

+0

Qu'est-ce que sha-of-commit? – kingsmasher1

+0

@ kingshasher1, sha = hachage SHA1, comme '3ba6ce43d500b12f64368b2c27f35211cf189b68'. – Dogbert