Git Basics

Basics

Adding a file and making commit

git add file
git commit -m 'Message'

Branching

Creating

git checkout -b myfeature develop

Merging

git checkout develop
git merge --no-ff myfeature

Deleting

git branch -d myfeature

List all branches

git branch -a

Renaming a branch

git checkout development
git branch -m develop ...
more ...

Git Going back

Going back

Revert the changes in uncommited but stagged changes

git reset --hard

Revert the changes in individual files

git checkout file

Simply unstag a file

git reset file.ext

Remove completely from history

git filter-branch --index-filter "git rm -rf --cached --ignore-unmatch FILENAME" HEAD

and then

rm -rf .git/refs ...
more ...

Git Remotes

Remotes

Working with remote repos

Push a local branch to a NEW remote branch changing names

git push origin cloropetas_vectores:feature/coropletas_vectores

Track an existing remote branch to an existing local branch

git branch --set-upstream cloropetas_vectores origin/feature/coropletas_vector
more ...

Git Tags

Tags

Tagging is useful because you can checkout a tag

git tag -a v1.2

Getting a particular tag

After the clone, you can list the tags with

git tag -l

and then checkout a specific tag:

git checkout tags/<tag_name>

Delete a remote tag

Just push an empty reference ...

more ...