That's my family!
Zoni
(29 a few times)
Zander (14)
Lauralynn
(11)
Owen (15.9)
Jason
(Dirt)
Commercial product from Atlassian
Git-based Distributed VCS (DVCS)
Projects
Repositories (Repos)
Branches/Tags
Commits
Code
Most of your work is actually done locally. commit is local. checkout is usually local. merge is done locally. You pull from remote to local.
Remote is the "golden" copy of the code. About the only thing you do with remote is push your local work to it. (OK, and fetch is used to pull remote branches, but you don't use it often.)
commit
checkout
merge
pull
push
fetch
Near
Far
git config [scope] [commands]
git config --global editor.core atom
git config --global alias.ec config --global --edit
git config --global alias.co "checkout"
git config --global alias.cob "checkout -b"
git config --global alias.cm "!git add -A && git commit -m"
git config --global alias.masterpull "!git co master && git pull"
git init - You will likely never actually use this, as it's for creating a new git repo locally. Typically, you'll want to create the repo in Stash first, and then clone it. Speaking of clone...
git clone [address to git file] - Makes a clone of the remote repository into a local folder (named the same as the remote repo)
git fetch
Fetches all of the branches available on the remote host
git checkout [branchname]
"Checks out" the branch indicated. Note that this will use local first, and then (if not found locally) attempt to checkout from the remote host
git pull
Creates a new local branch with the name indicated
git co [branchname]
git cob [branchname]
"Pulls" the code from the remote server for the branch you're currently in
git checkout -b [branchname]
git reset --hard HEAD
Resets your current branch to the HEAD commit of the current branch. Basically, it's your ultimate Undo button.
git add [files to add]
Adds the list of files provided to the local repository. Use -A to include all modified files.
git commit -M "Message here"
Commits all changes made (since last commit) to the local repository.
git cm "Message here"
Does both of the above with one step. (Aliases ROCK!)
git push
git push --set-upstream origin [branchname]
"Pushes" the code from the local repository for the branch you're currently in to the remote repository (The second command is required after creating a new local branch when pushing for the first time)
git stash
"Stashes" all modifications in a local cache. (FIFO)
git stash apply
Applies changes in the "stash" to the current branch.
git merge [branchName]
<item>
<id>OU812</id>
<genre>ROCKIN'</genre>
<artist>Van Hagar</artist>
</item>
<item>
<id>OU812</id>
<genre>ROCKIN'</genre>
<artist>Van Halen</artist>
</item>
<item>
<id>OU812</id>
<genre>ROCKIN'</genre>
- <artist>Van Halen</artist>
+ <artist>Van Hagar</artist>
</item>
As hard as it may be, resist the initial urge to just accept all of your changes as correct.
Merge conflict resolution is time-consuming but will ensure the proper information is retained.
This is the one area of using git where I HIGHLY recommend you use a diff/merge tool.
Free
Not Free (but the best)
will create a new commit to the feature branch which merges the master and featurebranches together.
git merge master feature
git checkout feature
git rebase master
will move the entire feature branch to begin at the tip of the master branch.
Creates a bit messier log/history, but can be used for all merging (public and personal)
Creates a "prettier" log/history, but should NEVER EVER be used on "public" branches, like master.
NEVER EVER NEVER NEVER NEVER EVER on master
Honestly, WAY outside the scope of this session. If you want more information about reverting commits, we should have another session. Hopefully, you won't need to. When you do, find a git guru to help!
git revert
git reset
Delete the folder, reclone.
(Don't feel ashamed. Everybody who has ever used git has probably resorted to this solution at least once.)