-
Couldn't load subscription status.
- Fork 8
Github workflow tips
- Quick links
-
How-to Q/A (using GitHub for Mac)
- What is a
gh-pagesbranch and what does it do? - How do I setup a website for my user or organization account?
- I want my repository to have a
gh-pagesbranch only! - How do I keep my
masterbranch and add agh-pagesbranch that mirrors themasterbranch? - How do I tag my branch with a version number and "freeze" a commit for future downloads?
- I'm constantly checking things in and out of my
masterbranch... Is this out of the ordinary? - How do I compare my
xxxbranch to myyyybranch??? - I'm using a Mac and
.DS_Storefiles suck, what should I do? - How do I globally tell Git to ignore specific types of files?
- How do I add a sidebar and/or footer to my WIKI pages?
- What's your general workflow for branches?
- How to create a "fresh" branch?
- How do I generate git.io short url for repos?
- Alternatives to the
master/developbranch workflow mentioned above? - Can commit messages contain references to issues?
- How do I resolve merge conflicts?
- How do I start a read-only repo on a server?
- I want to reference another repo from my repo ... How can I version control code inside of another repo?
- How do I setup Brew (Mac) to be the default Git command/resource?
- OMG! I've commited sensitive information to my repo/wiki, how can I undo????
- How to clone a specific branch?
- How to check for changes on remote (origin) git repository?
- Q: How do I change a folder name in a repository that's a Git sub-module of another repository?
- What is a
How-to Q/A (using GitHub for Mac):
A: A gh-pages branch is the repo name that GitHub uses to publish the contents of your branch to the web.
For example: http://registerguard.github.io/repo-name/demo/index.html
In other words, if you want to have GitHub host a demo page of your repo, FROM your repo (useing their servers), then you need to create a gh-pages branch on your repo (you'll also need create a website for your user/organization account in order for gh-pages to work ... see below).
A: That's pretty easy:
- Create a new repo named
username.github.comororganization.github.com: - Add an index.html file with
<p>Hello world</p>and add it to the repo. - Publish the repo.
- Create new/publish a
gh-pagesbranch, set it as the default (see below) and delete yourmasterbranch (optional, but only thegh-pagesbranch will be visible as a web page). - After a few minutes you should be able to access your files via http://username.github.com or http://organization.github.com (depending on which one you setup).
A: You'll need to create a gh-pages branch and delete your master branch.
- Push a
masterbranch. - Create/publish a new
gh-pagesbranch (based off of themaster). - Go to the repo's admin interface via the GitHub website and choose
gh-pagesas your default branch. - Now you can safely delete the
masterbranch using GitHub for Mac.
A: Here's how I do it:
- Create and publish a new
gh-pagesbranch based on mymasterbranch. - After a few minutes, you'll be able to access your repo's files via the web:
http://registerguard.com/repo-name/some-folder/some-file.ext (for example). - Later, update/commit changes to your master branch, open the Merge View panel and drag your
masterbranch into the left slot andgh-pagesinto the right slot. Click Merge Branches.
It's a manual process, but GitHub's mac UI makes it rather painless.
A: You'll have to do this via terminal:
- Navigate to your local repository.
- List current tags:
$ git tag. - Add a new tag:
$ git tag -a v0.1.0 -m "v0.1.0 stable". - Push the latest tag:
$ git push --tags.
Bonus!
- Delete the local tag:
git tag -d v0.1.0. - Delete the remote tag (which removes its download link):
git push origin :v0.1.0.
Bonus!!
Tag an older commit:
- List commits using:
$ git log --pretty=oneline, which outputs something like:
ce82fdf67a8205e4ddf5ca352dea5c1c4e8a9dd9 Hello universe!
12838cbd62e400a86e59a98323edfb4cb518496e Hello world!
- Next:
$ git tag -a v0.0.1 -m "v0.0.1 stable" 12838cb. - Finally:
git push --tags.
More information on tagging here:
A: Short answer? No. Long answer?
Some interesting workflow information can be found here:
A successful Git branching model
Inspired by that article, I've opted to create a develop branch for repositories that I frequently work on; so, my repos end up having a master, gh-pages and develop branch.
The nice thing about this workflow is that you can let your master branch be stable, and use your develop branch for the frequent check-in/outs. When you're ready to update master with the latest stable release, just merge develop into master and master into gh-pages.
A: There's some good info here:
It's pretty simple if you do it via a repo's Branches tab on the web; once there, just click on the Compare button.
Q: I'm using a Mac and .DS_Store files suck, what should I do?
A: Here's what I do:
If you don’t want OS X mucking up your Git repo with DS_Store files, you can set up a global ignore file. As per freshsauce, you simply execute the following two commands:
git config --global core.excludesfile ~/.gitignore
echo .DS_Store >> ~/.gitignore
How to globally ignore .DS_Store when using Git
See .DS_Store comments above, then read this.
On OS X Mountain Lion, the .gitignore_global file is located here:
~/user/.gitignore_global
... you can edit it directly.
Note: It's probably best to (also) add a .gitignore file to your repo; reasoning: You can't say for sure what type of setup someone has on the other end (i.e. someone forks your code and does a pull request). It's best just to include a .gitignore (and .gitattributes) and then you don't have to worry about rouge files. :)
A: Create pages named _sidebar and _footer (I think _header will work as well).
These new pages will show up as sidebars/footers on every page of your WIKI.
To edit these "special" pages, you can modify the URI directly, like so:
https://github.com/user-name/project-name/wiki/_sidebar/_edit and/or https://github.com/user-name/project-name/wiki/_footer/_edit
Alternatively, when you go to edit any page in your WIKI, the _sidebar and _footer pages are available to edit at the bottom of the page.
A: I work on develop and when it's stable I'll merge it to master and then I'll merge master to gh-pages. Pretty simple. :)
A: Currently, you'll have to use terminal to do this.
Here's the basics:
$ cd repo
$ git checkout --orphan gh-pages
Switched to a new branch 'gh-pages'
$ git rm -rf .
# Add your files, for example:
$ git add *
$ git add .gitattributes
$ git add .gitignore
# ... or whatever else needs to be added.
# Check status:
$ git status
# Once you're ready to commit:
$ git commit -a -m 'Hello world!'
$ git push origin gh-pagesI've found that there can be some issues between using terminal (to create a fresh branch) and GitHub for Mac, so I'd almost recommend to start with a "fresh" clone:
$ git clone https://github.com/user/repo.gitOr, use GitHub for Mac to download the repo, follow the above instructions, remove the repo from GH4M, remove the local repo folder and then re-clone the repo using GH4M.
A: Use:
$ curl -i http://git.io -F "url=https://github.com/..."
HTTP/1.1 201 Created
Location: http://git.io/abc123$ curl -i http://git.io/abc123
HTTP/1.1 302 Found
Location: https://github.com/...You can specify your own code to setup your own vanity URL:
$ curl -i http://git.io -F "url=https://github.com/technoweenie" \
-F "code=t"
HTTP/1.1 201 Created
Location: http://git.io/tMore info here.
A: Yes! I've seen some repos that use the master branch as their "unstable" repo, and they've got a "version" branch that's "stable".
Example:
In essence, this is the opposite of the workflow I'm using (where master branch is "stable" and develop branch is "unstable").
The one drawback to my workflow is that my gh-pages branch is based on master (for demo purposes). I really wish there was a gh-demo-pages branch. :D
A: Yes! Just use #XX where "XX" is the issue number. This shortcut also works in issues themselves and their comments.
Note: If you reference an issue number in a commit then that issue will get closed automatically.
A: Crack open terminal and run:
$ git statusLook for a section that says:
Unmerged paths
From there, run:
$ git add <file>And you can go from there (I jump back into GitHub for mac and the conflicted file(s) should be good to go now).
More info here:
How to resolve Git merge conflict
A: Log onto your server and make sure git is installed:
$ which gitif not, install it.
Once git is there, on server, clone:
$ git clone https://github.com/registerguard/bulldog.gituse the git:// version for both pushing and pulling (not read-only) why?
... and that's it!
TIPS:
Do:
$ git log... before/after to see diffs (see what version you got and/or what's changed).
Use:
$ git pull... to update the local repo to the latest version.
Note:
$ git status... does not apply to "read-only" repos.
Q: I want to reference another repo from my repo ... How can I version control code inside of another repo?
A: Use git submodules!
There's a really good walkthrough here:
Here's some quick tips:
- Download your repo,
cdto the root of the project tree and run$ submodule add [email protected]:username/repository.git path/to/desired/module/location(make sure the target folder doesn't already exist). - On your production server, to get a repo initialized, run
$ git clone --recursive [email protected]:username/repository. - To update a submodule,
cdto the submodule directory and run$ git pull; if you get an error like "you aren’t on any branch" then run$ git checkout master. - Other?
Note: You might consider using https, instead of git@, as the latter won't require authentication. Choose wisely. :)
A: Easy!
First, get your current Git version:
$ git --version... and the path:
$ which git... next:
$ brew update... then:
$ brew install git... and:
$ brew doctorNow, start a new terminal session and run the above $ git --version and $ which git commands.
See here for more tips on using Brew.
A: Yah, that sucks ...
Here's one way:
What has worked for me:
- Clone the repo (using a WIKI as an example):
$ git clone https://github.com/user/repo.wiki.git
- Move to that directory:
cd repo.wiki/ - Delete the hidden
.gitfolder. - Initialize a new repository in the same folder and link it to github:
$ git init $ git remote add origin [email protected]:user/repo.wiki.git
- Now commit your current version of code:
$ git add * $ git commit -am 'Hello world!'
- Finally, force (
-f) update on GitHub:$ git push -f origin master
The same/more info can be found here:
how to delete all commit history in github
A: If you have git >= 1.7.10:
$ git clone -b mybranch --single-branch git://sub.domain.com/repo.gitstackoverflow: Clone only one branch
A: Some of these have been stated already, but these work well when used together:
$ git log # shows what happened (like a git history) (use 'q' to quit)
$ git status # Shows you current status of commits
$ git diff # Shows difference between local and github repo. (use 'q' to quit)Other options:
# Bring your remote refs up to date:
$ git remote update
# Test whether the branch you are tracking is ahead, behind or has diverged;
# If it says nothing, the local and remote are the same:
$ git status -uno
# This command will show you the commits in all of the branches
# whose names end in master (eg master and origin/master):
$ git show-branch *masterShort version to see if you're ahead or behind:
$ git remote update && git status
A:
- Clone sub-module repo locally.
- Make sure you're working on the right branch (in this case, I want to be in
master).
- Make sure you're working on the right branch (in this case, I want to be in
- Make changes to folder name.
- If necessary, update
gh-pagesdemo branch.
- If necessary, update
- Push back to GitHub.
Done.