Git terms and commands

Git terms and commands

getting to know the git lingo

·

2 min read

Common Git terms

TermIdea
repository (aka repo)project folder
local repository (aka local)project folder on a personal computer
remote repository (aka remote)project folder on the Internet (a server, perhaps?)
staginga selection of files from the project folder
committingconfirming the selection of files as a change to the project
pushinguploading the confirmations to the project folder on the Internet
cloningcopying a project folder from the Internet to one's computer
forkingcopying someone else's project from the Internet onto one's own account
branchingcreating a parallel version of a project (which can later merge back)
checkoutsetting a branch as the current working branch
mergingcombining a version with another version of a project

Common Git commands

Type git plus any of the following:

CommandIdea
initcreates or initializes a new local repository
add -Aadds all the changes to the Git repository to "staging"
commit -m "message"updates the local repository with all the changes previously added to "staging" (tagged with a message summarizing the changes made)
remote add origin [repourl]connects the local repository with a remote repository (usually on GitHub.com)
push [origin] [branch]uploads the most recently committed changes
clone [repourl]downloads a remote repository to one's own computer
checkout [branchname]switches to a branch in the local repository (assuming it exists)
checkout -b [newbranchname]creates a new branch in the local repository
branch -adisplays a list of all branches
statusdisplays the current status of the local repository, i.e.:
pull [branch]retrieves the latest changes of a working version from the remote to the local
diffdisplays a list of code changes since the last add

Typical workflow

# making a commit and pushing it online
$ git add -A
$ git commit -m "adding all files"
$ git push origin development

# getting code other people did (if any)
$ git pull support/newbranch

# doing an experiment (branching)
$ git checkout -b support/newbranch devlopment
$ git branch -a

# finding out the status of a project
$ git status
$ git diff