Table of Contents
Basics
Record changes to the local and remote repositories
The steps below are applied when there is some files, in the local repository, ready to be pushed to the remote repository.
- Open a terminal in the local repository and add the files to the stage area:
git add --all
or
git add <name-file>
Before commit the files it's possible to do as many changes as necessary to them, and when they are finally ready, run the add
command again.
- Commit the changes:
git commit -m '<your message here>'
- Push to the remote repositoy:
git push origin master
or
git push origin <name-branch>
To force files to be pushed in the remote repository, overwriting the existing ones:
git push -f origin <name-branch>
Check the status of the local repository
The following commands are used to inspect the status of the local repository relative to the remote one.
git remote update git status
See differences
To see if there are any difference between the working directory and the HEAD:
git diff HEAD
List commit logs
To get he list of commits present in the local repository:
git log --oneline
List files committed
git show --pretty="" --name-only HEAD
Update the local repository
To fetch changes from the remote repository and merge them into the local one:
git pull
To force files to be pulled in the local repository, losing changes not already pushed in the remote one:
git fetch --all git reset --hard origin/<name-branch>
Delete Last Commit from Remote Repo
To delete only the last commit from the remote repository, without affecting the local:
git push origin +HEAD^:master