Git tips

How to change remote URL of Git repository ?

To manage tracked repositories we can use a command called remote set-url: git remote set-url origin http://my_new_tracked_repository.com ...

Continue Reading β†’

How to delete one branch ?

Git 1.7 brings a possibility to delete a branch with simple push command. This command should only define deleted branch with --delete branch_name suffix, as below: git push origin --delete my_bran...

Continue Reading β†’

How to get information about specific commit ?

It's possible with git show command. For example, to get information about commit xxyy, we should execute: git show xxyy The output should return: commit author, commit date, commit message an...

Continue Reading β†’

How to revert local commit ?

When one commit is not pushed to remote branch, it can be reverted with simple git reset command. Below you can find an example to revert the last not pushed commit: git reset --soft HEAD~1 HE...

Continue Reading β†’

How to commit with message composed by many paragraphs ?

Normal commit is composed by files and message. The last one is defined thanks to -m flag. To send more than one paragraphs in commit message, we can use several -m flags in commit operation: git...

Continue Reading β†’

How to remove files but keep them locally ?

One of the possible solutions for this problem is...git rm. But defined as it, it will remove both, remote and local files. To remove file from repository but keep them as untracked locally, --cached ...

Continue Reading β†’

How to undo not pushed deleted file ?

Recently I had to deal with a strange issue of IntelliJ when I've trying to move my Scala class to other package. The class looked like in the following snippet: case class FirstCaseClass(....) ca...

Continue Reading β†’

What does -- means in git reset command ?

Basically git reset command helps to reset current HEAD to specified state. It can be used for instance to undo X commits or merges. But it can also be used to reset a single file in the index. Let...

Continue Reading β†’

How to ignore nested files in .gitignore?

Sometimes, especially when you use submodules or subpackages in your project, you will need to ignore locally generated files on them. The default .gitignore wildcard expression like *.txt should help...

Continue Reading β†’