Let's say you have a gist (public or private) and someone forks it and makes changes to it. Awesome! However, now you want to merge in their changes to your gist. Unfortunately, it doesn't seem GitHub supports this via their website at the moment, however, you can still merge the gists with 'git' on the command line.
-
You want to clone your gist. You can locate the link for this under "Clone this gist"
➜ ~/dev » git clone https://gist.github.com/5315168.git Cloning into '5315168'... remote: Counting objects: 6, done. remote: Compressing objects: 100% (4/4), done. remote: Total 6 (delta 1), reused 0 (delta 0) Unpacking objects: 100% (6/6), done. ➜ ~/dev » cd 5315168 ➜ ~/dev/5315168 ‹master› » ll total 16K -rw-r--r-- 1 yano yano 3.3K Apr 4 19:12 gistfile1.txt drwxr-xr-x 8 yano yano 4.0K Apr 4 19:12 .git
-
Add the forked gist as a remote.
➜ ~/dev/5315168 ‹master› » git remote add fork1 https://gist.github.com/5315193.git
-
Pull down the remote.
➜ ~/dev/5315168 ‹master› » git pull fork1 master remote: Counting objects: 5, done. remote: Compressing objects: 100% (2/2), done. remote: Total 3 (delta 1), reused 0 (delta 0) Unpacking objects: 100% (3/3), done. From https://gist.github.com/5315193 * branch master -> FETCH_HEAD Updating a436dd9..e4fedc7 Fast-forward gistfile1.txt | 2 ++ 1 file changed, 2 insertions(+)
-
Push back up to your gist. You'll need to enter your credentials.
➜ ~/dev/5315168 ‹master› » git push Username for 'https://gist.github.com': myano Password for 'https://[email protected]': Counting objects: 5, done. Delta compression using up to 4 threads. Compressing objects: 100% (2/2), done. Writing objects: 100% (3/3), 279 bytes, done. Total 3 (delta 1), reused 0 (delta 0) To https://gist.github.com/5315168.git a436dd9..e4fedc7 master -> master
-
See the changes at your gist, https://gist.github.com/myano/5315168 You can see that the history is preserved.
After some quick testing it appears that gist does not understand or care about other branches besides master.