Skip to content

basic git commands ​

remotes ​

change a repository remote called origin

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

branches ​

move to a branch

bash
git checkout <branch_name>

create and move to a new branch

bash
git checkout -b <branch_name>

delete a branch

bash
git branch -d <branch_name>

rename a branch

bash
git branch -m <renamed_branch>

files ​

add all changed files to the index

bash
git add --all

add one changed file to the index

bash
git add <file_relative_path>

references: rubygarage

commits ​

commit changes

bash
git commit -m "your_commit_message"

push ​

push a branch which already connected and exist in remote

bash
git push

push a branch which doesn't exist on remote yet

bash
git push -u <upstream> <branch_name>

status ​

bash
git status

configurations ​

read configured user in current repo

bash
git config user.name
git config user.email

read configured global user

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

configure user in current repo

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

configure global user

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

initialize a git repo ​

bash
git init