Administration Système

Every day Git commands for developers

Here are some day to day useful git commands

Show all remotes (origin and upstream)

git remote -v
git remote show origin #shows branches, tags etc.
git remote show upstream #shows branches, tags etc.

Add upstream remote (vs origin remote)

git remote add upstream

Remove a file from a Git repository without deleting it from the local filesystem

For single file:

git rm --cached myremotefiletodelete.log
git commit -m "remove file from repo"
git push

For single directory:

git rm --cached -r myremotedirectortytodelete
git commit -m "remove folder from repo"
git push

Shortcut add & commit all files

Without shortcut

git add .
git commit -m "commit message"

With shortcut

git commit -am "commit message"

Leave a Reply

Your email address will not be published. Required fields are marked *