Skip to content

Instantly share code, notes, and snippets.

@keegoid
Created August 19, 2014 13:18
Show Gist options
  • Save keegoid/a1766a151beedf83bfb7 to your computer and use it in GitHub Desktop.
Save keegoid/a1766a151beedf83bfb7 to your computer and use it in GitHub Desktop.
A description of my current workflow for Markdown and git.
## workflow
#### Markdown
After much tribulation with [Markdown][md] editors and various workflows, I've found what I think is a great way to create/maintain my [Markdown][md] docs.
For blog posts or any long-form writing, [Draft][draftin] is wonderful, especially the `F11` mode. It mostly works with [GitHub Flavored Markdown][gfm] except for strikethrough and alignment of table columns.
I then *Export* my document to the appropriate [git][git] repository in [Dropbox][db] (which then syncs with my various devices).
Finally, I commit the new document with [git][git] and push it to the remote repository (which then gets automatically built and deployed on [BitBalloon][bb]).
For other [Markdown][md] docs like *README.md* or *LICENSE.md* I find [gEdit][ge] to be easy and efficient. I can make some quick edits, commit changes in [git][git] and push them to [GitHub][gh] with just a few commands. It's also easy to repeat commits and pushes with the keyboard up arrow from the Terminal.
to commit again: `up up enter`, to push again: `up up enter`
#### git remote
If you didn't start by cloning an existing repository on GitHub, you'll need to add your remote origin URL:
```bash
# HTTPS:
git remote add origin https://github.com/yourusername/linux-deploy-scripts.git
# SSH:
git remote add origin git@github.com:yourusername/linux-deploy-scripts.git
```
You can also set the upstream repository to fetch changes from this project:
```bash
# HTTPS:
git remote add upstream https://github.com/keegoid/linux-deploy-scripts.git
# SSH:
git remote add upstream git@github.com:keegoid/linux-deploy-scripts.git
```
Then `git fetch upstream master` and `git merge upstream/master`
or accomplish both with `git pull upstream master`
#### git push and pull
```bash
# commit changes with git:
git commit -am 'update README'
# set the default push and pull methods for git to "matching" with:
git config --global push.default matching
git config --global pull.default matching
# create a new branch and check it out:
git checkout -b 'branch-name'
# link the origin/<branch> with your local <branch>:
git branch --set-upstream-to=origin/branch-name branch-name
```
Now you can simply use `git push` or `git pull` from your current branch, including master. It's nice to be able to reduce the length of these commands so you don't have to think about what you're pushing or pulling each time. Just make sure you've got the right branch checked out!
**long versions**
push or pull changes to/from origin (GitHub):
`git push origin master` or `git push origin branch-name`
`git pull origin master` or `git pull origin branch-name`
Note, use `git config --list` to view all configured options.
I hope you find this workflow as efficient and effective as I do.
[git]: http://git-scm.com/
[gh]: https://github.com/
[gfm]: https://help.github.com/articles/github-flavored-markdown
[md]: http://daringfireball.net/projects/markdown/
[ge]: https://wiki.gnome.org/Apps/Gedit
[bb]: https://www.bitballoon.com/
[db]: https://db.tt/T7Pstjg "clicking this affiliate link benefits me at no cost to you"
[draftin]: https://draftin.com/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment