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 [email protected]:username/git-repo.git

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 fileToAdd.txt
git commit -m "commit message"

Show git commit history (pretty format)

 git log --pretty=format:"%h - %an, %ar : %s"

Leave a Reply

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