Changes

From Genome Analysis Wiki
Jump to navigationJump to search
1,561 bytes added ,  17:18, 9 September 2011
Update FAQs
Line 35: Line 35:  
#* <code>git commit -m ''Initialize the repository with all the files''</code>
 
#* <code>git commit -m ''Initialize the repository with all the files''</code>
    +
Note: The <code>shared</code> parameter on <code>git init</code> allows everyone in the same group to push to this repository.  If this is the case, add that parameter.
    
Continue to the next section if you want to create a bare repository for it to push to/pull from.
 
Continue to the next section if you want to create a bare repository for it to push to/pull from.
Line 175: Line 176:  
* git push origin ''branchName''
 
* git push origin ''branchName''
   −
== Work on a branch that exists on the remote ==
+
== Work on/Use a branch that exists on the remote ==
 
*To see all branches including remotes:
 
*To see all branches including remotes:
 
** git branch -a
 
** git branch -a
 
* Base work on a remote branch/merge back to it
 
* Base work on a remote branch/merge back to it
** git checkout --track origin/''branchName''
+
** git checkout -t origin/''branchName''
 
** Creates & checkouts branch called ''branchName''
 
** Creates & checkouts branch called ''branchName''
 
* Now push & pull from your ''branchName''
 
* Now push & pull from your ''branchName''
 +
 +
Note: A typical wrong way is: clone from the remote repository, then pull the branch
 +
 +
Note: A local branch name is only informative to you.  There is no relationship between that branch name and the branches named at the repository that you initially did the pull from.  So you may, for example, name your local branch "fix_karma_paired_end" or anything else arbitrary even if the remote branch is "0.8.8S".  As described above, the -t option will create a local branch named after the remote branch, also specify -b if you want to customize the name.
    
== Resolve a merge/pull conflict ==
 
== Resolve a merge/pull conflict ==
Line 193: Line 198:  
resolved the merge
 
resolved the merge
 
* You can also use a mergetool: git mergetool
 
* You can also use a mergetool: git mergetool
      
== Create a tag ==
 
== Create a tag ==
Line 213: Line 217:  
* Not automatically pushed to the remote
 
* Not automatically pushed to the remote
 
* git push origin ''tagName''
 
* git push origin ''tagName''
 +
 +
== Setup an email hook on pushes ==
 +
* cd ''yourDirectory''/.git/hooks
 +
* cp post-receive.sample post-receive
 +
* Uncomment the line at the end of post-receive that references post-receive-email
 +
* Add the following to ''yourDirectory''/.git/config:
 +
<pre>
 +
[hooks]
 +
mailinglist = "space delimited email addresses to email when changes are pushed"
 +
</pre>
 +
 +
== "Push rejected non-fast forward" ==
 +
Two possible answers:
 +
 +
(1). You did not pull the current branch before trying to push.
 +
 +
Solution: do a <code>git pull</code>, then retry the <code>git push</code>
 +
 +
(2). You only pulled a branch but want to push it back to master branch.
 +
 +
== Committed to the wrong branch ==
 +
If you have NOT yet pushed to a public repository and it was the last commit:
 +
*git reset --soft HEAD^
 +
** puts the changes back to staged.
 +
git checkout branch_you_want
 +
git commit

Navigation menu