How to

Push

Push to a remote specific branch

Assuming as an example that the remote upstream has been added and you need to send code from the local branch develop to the remote branch dev-master, to be able to execute this operation just execute the command below:

git push upstream develop:dev-master

Push ignoring verify or hooks

git push github develop:master --no-verify

Ignore all files in this folder

When you want to ignore files but want to keep a directory you can add a .gitignore file within the desired directory with the following content

*
!.gitignore

Get current branch

git branch --show-current

Cache

Clear Entire Git Cache

To clear your entire Git cache, use the “git rm” command with the “-r” option for recursive

When all files are removed from the index, you can add the regular files back (the one you did not want to ignore)

Cache user and password

Stash

Stash including untracked files

Stash only file or folder

Revert

Revert files from a specific hash commit

Revert to a specific commit

Reset

Reset Permissions

When you accidentally modify the permissions of versioned files, it is possible to return to the initial permission state using the command below

Use globally

If you want to use globally, you can do it that way:

Reset by time

Undo the last commit

Rename

Rename your branch

If you are on a different branch:

  • Delete the old-name remote branch and push the new-name local branch.

git push origin :old-name new-name

  • Reset the upstream branch for the new-name local branch.

Switch to the branch and then:

Logs

Find versioned files

To find files that have been versioned, regardless of whether they were removed from versioning or not.

View git logs of just one author commits

View git logs of many authors commit

Exclude git commits log from one or more author

Proxy bypass to specific host

Fixing wrong commit messages

Deleting remote branches

Keeping a fork up to date

Clone your fork:

Add remote from the original repository in your forked repository:

Updating your fork from the original repo to keep up with their changes:

How to use prune to Clean Up remote branches

Using "prune" on a Remote Repository

The easiest way to use prune is to provide it as an option when fetching:

In cases where you'd like to only perform a prune and not fetch remote data, you can use it with the git remote command:

If you want to have prune executed with every fetch operation, you can configure Git accordingly:

Tags

Create and tag with a message

Last updated

Was this helpful?