Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
git:faq [2009/10/18 22:38]
janakj
git:faq [2010/01/12 13:38] (current)
Line 1: Line 1:
 +~~NOTOC~~
 ====== Git Frequently Asked Questions ====== ====== Git Frequently Asked Questions ======
- +==== How do I tell git to ignore my local changes to file XYZ from the repository? Can I use .gitignore for that? ==== 
-===== How do I tell git to ignore my local changes to file XYZ from the repository? Can I use .gitignore for that? =====+----
 No, you cannot use ''.gitignore'', because that only works on files that are not being tracked in the repository. If you want to tell git to ignore your local changes to file XYZ, use the following command: No, you cannot use ''.gitignore'', because that only works on files that are not being tracked in the repository. If you want to tell git to ignore your local changes to file XYZ, use the following command:
  
Line 8: Line 9:
 The command above sets a special flag for the file XYZ which makes git ignore any you did in your copy of the file. The flag remains in effect until you cancel it again with the following command: The command above sets a special flag for the file XYZ which makes git ignore any you did in your copy of the file. The flag remains in effect until you cancel it again with the following command:
  
-  $ git update-index -no-assume-unchanged XYZ+  $ git update-index --no-assume-unchanged XYZ
  
 See ''man git-update-index'' for more details. See ''man git-update-index'' for more details.
 +
 +==== Is there a way to pull a version of the code as it was at a certain date? ====
 +----
 +You can check out what in the repository a week ago without a branch (it would be
 +difficult to make/commit changes) with:
 +
 +  $ git checkout origin/master@{"1 week ago"}
 +
 +The same thing, but creating a new local branch ''master_old'' with the
 +content from 1 week ago:
 +
 +  $ git checkout -b master_old origin/master@{"1 week ago"}
 +
 +==== How can I push my local branch into the shared repository? ====
 +----
 +**Question**:
 +
 +If I push my local branch 'abcd' into the shared repository, it seem that git wants to create a new branch:
 +
 +  $ git push origin abcd --dry-run
 +  To ssh://username@git.sip-router.org/sip-router
 +  * [new branch] abcd -> abcd
 +
 +Which is not what I really want, I want to push it into the existing master branch instead.
 +
 +**Answer**:
 +
 +You need to specify the name of the branch in the remote repository
 +you want to push to if the name of the local branch and the name of
 +the remote branch are not same:
 +
 +  $ git push origin abcd:master
 +
 +If you omit the name of the destination branch after colon then git assumes that it is the same as the name of your source branch.
 +
 +==== How to see the diff of commits between branches? ====
 +----
 +
 +**Question**
 +
 +Branches during testing period can unsync via --cherry-pick commits, is there a way to see what commits were done only in a specific branch?
 +
 +**Answer**
 +
 +A quick way to see the different commits (commits on k_3.0 that are not on sr_3.0) is:
 +
 +  git log --oneline --left-right --cherry-pick origin/sr_3.0...origin/kamailio_3.0 |grep "^>"
 +
 +(the simpler git log --oneline origin/sr_3.0..origin/kamailio_3.0 cannot be used because k was updated with cherry-pick and not with merge)
 +
  

Navigation

Wiki

Other

QR Code
QR Code git:faq (generated for current page)