Git: Difference between revisions

From dankwiki
1,229 bytes added ,  03:10, 6 December 2021
No edit summary
(11 intermediate revisions by the same user not shown)
Line 37: Line 37:
* In <tt>workpath/</tt>, run <tt>git add .</tt>
* In <tt>workpath/</tt>, run <tt>git add .</tt>
* In <tt>workpath/</tt>, run <tt>git push</tt>
* In <tt>workpath/</tt>, run <tt>git push</tt>
===Prune remote branches===
<tt>git remote prune origin</tt>
This can be made automatic with <tt>git config remote.origin.prune true</tt> since git 1.8.5.
===Hard sync to upstream===
Warning: this will throw away even committed local changes! Assuming remote <tt>upstream</tt> and branch <tt>master</tt>:
<tt>git reset --hard upstream/master</tt>
then, to force your own fork to match:
<tt>git push origin master --force</tt>
Congratulations! You've just thrown away any local work.
===Remove local+remote tag===
* <tt>git tag -d TAG</tt>
* <tt>git push --delete origin TAG</tt>
===Rename local+remote branch===
Remote branches cannot be renamed in a single step. Instead,
* Check out the remote branch if it is not checked out
* Rename the local branch with <tt>git branch -m newname</tt>
* Delete the remote branch with <tt>git push origin ––delete oldname</tt>
* Re-add and reset the remote branch with <tt>git push origin –u newname</tt>
===Find commit corresponding to tag===
* <tt>git rev-list -n 1 TAG</tt>
===List all commits between two hashes Ce and Cb===
* <tt>git rev-list Ce..Cb</tt>
===Update local list of remote branches===
* <tt>git remote update origin --prune</tt>
==See also==
* [[GitHub]]
* Tv's "[ Git for Computer Scientists]"
* Tv's "[ Git for Computer Scientists]"