Basic Git Commands

Remotes

Change a repository remote called origin

git remote set-url origin user@server.tld:group/repo.git

Branches

Move to a branch

git checkout <branch_name>

Create and move to a new branch

git checkout -b <branch_name>

Delete a branch

git branch -d <branch_name>

Rename a branch

git branch -m <renamed_branch>

Files

Add all changed files to the index

git add --all

Add one changed file to the index

git add <file_relative_path>

References: RubyGarage

Commits

Commit changes

git commit -m "your_commit_message"

Push

Push a branch that is already connected and exists in the remote

git push

Push a branch that doesn't exist on the remote yet

git push -u <upstream> <branch_name>

Status

git status

Configurations

Read configured user in the current repo

git config user.name
git config user.email

Read configured global user

git config --global user.name
git config --global user.email

Configure user in the current repo

git config user.name "your_name"
git config user.email "your_email"

Configure global user

git config --global user.name "your_name"
git config --global user.email "your_email"

Initialize a Git repo

git init