Skip to content

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 which already connected and exist in remote

git push

push a branch which doesn't exist on remote yet

git push -u <upstream> <branch_name>

status

git status

configurations

read configured user in 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 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