Git basics

11
GIT Basic commands

Transcript of Git basics

Page 1: Git basics

GITBasic commands

Page 2: Git basics

Change username, e-mailGloballygit config --global user.namegit config --global user.emailFor a repogit config user.namegit config user.email

Page 3: Git basics

Change remote originCheck all branches and its trackinggit show remote origin

Change branch trackinggit branch branch_name -u <your_new_remote/branch_name>

Page 4: Git basics

Clone and pullRebase rolling commits abovegit pull --rebaseRefreshgit fetch -p

Page 5: Git basics

Clean and reset branchesDelete untracked files and folders

git clean -fdMake a local branch identical to a remote one

git reset --hard origin/<branch_name>

Page 6: Git basics

Diff and mergeDiffgit diff <commit_id>git difftool <commit_id>Mergegit merge <branch_name>git mergetool <branch_name>

Page 7: Git basics

Delete branchesTo remove a local branch from your machine:git branch -d the_local_branchgit branch -D the_local_branchTo remove a remote branch from the server:git push origin :the_remote_branchgit push origin --delete the_remote_branch

Page 8: Git basics

Adding external repositoriesgit submodule add <repo.git> <local folder>git submodule initgit submodule update

Page 9: Git basics

Configure remote branch trackinggit branch -u upstream/foo

Page 10: Git basics

PatchesGenerate a patch from the last commitgit format-patch -1 HEADApply a patchpatch -p1 < file.patch

Page 11: Git basics

Coloursgit config --global color.ui auto