git initMakes a new empty git repository.
git add FILEStages changes in
FILEfor the next commit.
git status Shows the status of the repository.
git config --global user.name NAME
git config --global user.email EMAIL
git config --global core.editor jpico
# After you've staged some stuff git commit
# Create a new branch git branch newBranch # Check it out git checkout newBranch
# Create and checkout a new branch in one step git checkout -b newBranch
Merge changes from another branch into this branch.
If we wanted to merge changes from
# Switch to master git checkout master # Merge changes from newBranch into the current branch (master) git merge newBranch
If you're lucky, git will do everything for you!
CONFLICT (content): Merge conflict in some-file.txt Automatic merge failed; fix conflicts and then commit the result.
some-file.txt, we see...
<<<<<<< HEAD The current branch’s contents ======= Stuff from the branch you’re merging >>>>>>> newBranch
git statusfor a list of files with conflicts.
some-file.txt), so that it looks the way it's supposed to.
git add) and commit (
git logShow a log of commits
--graphNeat ASCII graph
-pShow what changed in each commit
git diff Show uncommitted changes
--allShow all branches
git gui Graphical tool for committing
It is often (usually) useful to have a central place where you (and your teammates) can store your repository.
By setting up a remote repository, you can more easily backup your work and share it with others.
git clone REPOdownloads a copy of a repository.
git pushPushes changes from your current branch to the remote branch it tracks.
git pullPulls changes from the remote branch and merges them into your current branch.
git remoteallows you to edit git's information about remote repositories
a.out) to your repo.
.gitignorefile in your repo.
git help <command>will show you documentation.