== What is this miscellaneous file, and how does it compare to what's in my repo? ==
Say you've got a config file lying around (untracked) in your local working tree. It's not in your current project branch, but you know it's an important file. How does it compare to what's in the '''freephile''' remote, '''es128''' branch version of the file?
<source lang="bash">
== Compare a file between branches ==
Do you think a particular file has changed between two separate feature branches (ea based off master)?
<source lang="bash">
== Git Branch ==
* list the branches you have locally <code>git branch --list</code>
* list the branches that are on remotes <code>git branch -r --list</code>
* checkout a remote branch, setting the local one to track <code>git checkout -t freephile/patch-1</code>
* git branch --merged (while on master) shows you branches which are fully contained in HEAD, and can be deleted.
== Comparing local to upstream ==
If you do a <code>git status</code> and it tells you that your (local) branch is behind the remote tracking branch, then maybe you want to look at what those changes are.
<pre>
# On branch master
# Your branch is behind 'freephile/master' by 6 commits, and can be fast-forwarded.
# (use "git pull" to update your local branch)
</pre>
Tell git to fetch the branch named 'master' from the remote named 'origin'. Git fetch will not affect the files in your working directory; it does not try to merge changes like <code>git pull</code> does.<br />
<code>git fetch origin master</code>
When the remote branch is fetched, it can be referenced locally via FETCH_HEAD. Tell git to diff the working directory files against the FETCHed branch's HEAD and report the results in summary format.<br />
<code>git diff --summary FETCH_HEAD</code>
If you want to see changes to a specific file, for example myfile.js, skip the --summary option and reference the file you want (or tree). Note: paths (or pathspecs) should be separated from command options with a double dash (<code>--</code>)<br />
<code>git diff FETCH_HEAD -- mydir/myfile.js</code>
== Comparing Branches ==
What's in this old branch, not in my new branch (ignoring merges)?
* git log oldbranch ^newbranch --no-merges
== Don't merge, Rebase! ==
Get familiar with how to rebase your work each day http://www.bitsnbites.eu/a-tidy-linear-git-history/
== Delete local and remote merged branches ==
<source lang="bash">
git branch --merged | egrep -v "(^\*|master|dev)" | xargs -I % echo 'git branch -d % ; git push --delete freephile % ;'
== Git Log ==
What's the commit history? The [https://git-scm.com/docs/git-log man page for git log] is so big, it's a forest. There are examples in the book for [https://git-scm.com/book/en/v2/Git-Basics-Viewing-the-Commit-History viewing commit history]. For a quick cheatsheet, try these.
== Tags ==
With git, you can just tag something with <code>git tag foo</code>. This produces a 'lightweight' tag <ref>[https://stackoverflow.com/questions/21031201/how-can-i-list-all-lightweight-tags how can I list all the lightweight tags]</ref>. Use "annotated tags" whenever you want to know '''when''' something was tagged and '''who''' did it. Pass an empty message if you really don't care or need extra annotation.
<source lang="bash">
== [https://stackoverflow.com/questions/12921125/git-merge-branch-of-another-remote Git merge branch of another remote] ==
When using git between a local repository and a single 'origin' remote, it's a simple process to work locally and push things back up to origin. But, what if you have a separate remote repository... perhaps on GitHub, or a collaborator who has similar sources but not using your origin (so disconnected, and perhaps not even linked ancestrally like a fork). How do you add that other remote to your project and then pull in the code "they" have on top of yours? Here's an example of how we started with a repo from github and added a repo that we were developing privately. (The reality is that we were developing a repo privately; created a sibling version of the code at github; and then wanted to re-incorporate the changes of the github repo back into our private repo.)
<source lang="bash">
== Unbloat ==
https://stackoverflow.com/questions/3797907/how-to-remove-unused-objects-from-a-git-repository
== Put your project on GitHub ==
Been hacking away on a project and now it's time to unveil it? Here are the quick and easy steps to get your local repo into your GitHub account.
<source lang="bash">