ALL
Useful git commands in daily work
In a developer's daily work, it is frequent to see lots of commits made. It would be a headache if one cannot use git commands well especially when in cases where some fixes need to be made on existing branches. There are some frequently used command such as git pull, git merge and git push. Apart from these, there are some other practical commands which may be useful for real use cases. This post will try to list some of them.git grep It will lists all files containing the searched keyword. This is similar to the Linux command grep.git blameIt will list the author and change time of each...
1,741 0 GIT LOG GIT COMMAND GIT
Fix could not read Username for 'https://xxx.com': terminal prompts disabled
Recently was working on a project which needed to build a docker image, but unfortunately it kept failing as below error was seen.fatal: could not read Username for 'https://xxx.com': terminal prompts disabledBased on the error, it looked like it was trying to pull code from remote Gitlab repository but failed as the terminal prompt is disabled.At first glance, have a doubt why it needs terminal prompt to be enabled? It should just succeed and without prompting for anything. The only reason for prompting is that it needs user authentication to login to the remote Gitlab repo and fetch code.&nb...
9,991 0 GIT DOCKER TERMINAL PROMPTS DISABLED
Simple tutorial on git cherry-pick
It is a common operation to move code from one branch to another branch in a multi-branch git repository. Normally there are two scenarios:Want to move all changes in one branch to another branch, now it's called git merge Want to move only some change/changes from one branch to another branch, now it's called git cherry-pickUsageThe purpose of git cherry-pick is to apply some change from one branch to another branch. git cherry-pick [commitHash]The above command is to apply the commit commitHash to the current working branch. It will create a new commit in the current working b...
8,615 0 TUTORIAL GIT GIT CHERRY-PICK
How to undo git changes?
When using git for version control, there is frequent need on undoing commits due to some unexpected changes. This post will introduce how to undo changes with git command in different cases.Undo commitA common undo case is that some commit needs to be reverted as the commit contains error. In this case, the code is already committed. The command to revert the commit isgit revert HEADThis command will add new a commit to the existing head to undo the previous commit. It will not change the previous commit history, hence there is no risk of losing changes.If need to revert multiple commits, run...
3,593 0 GIT CHECKOUT GIT REVERT GIT RESET GIT
A simple example of git bisect command
git bisect is a very powerful command for finding out which commit is a bad commit when bug occurs. The rationale behind this command is that it pin locates the bad commit by divide and conquer. It divides the commit history into two equal parts, then determines whether the bad commit is at the first half or at the other half. This process will continue until the bad commit is located.Here is a really good example created by bradleyboy, this is a simple git repository which demonstrates a bad commit in the index.html. First, please clone the repository into local.$ git clone git@gith...
18,665 2 GITHUB GIT GIT BISECT
Resolve git issue git@github.com: Permission denied (publickey)
Sometimes when clone a remote repository from github.com, you may see below error.D:\Project\Playground\GitBisect>git clone git@github.com:bradleyboy/bisectercise.gitCloning into 'bisectercise'...git@github.com: Permission denied (publickey).fatal: Could not read from remote repository.Please make sure you have the correct access rightsand the repository exists.The issue occurs when there is no key on your machine which is associated with your github account. To fix the issue, please go to ~/.ssh and check whether you have correct private and public key generated and stored and associate th...
18,418 0 GITHUB PERMISSION DENIED GIT PUBLIC KEY
git reset vs git revert
When maintaining code using version control systems such as git, it is unavoidable that we need to rollback some wrong commits either due to bugs or temp code revert. In this case, rookie developers would be very nervous because they may get lost on what they should do to rollback their changes without affecting others, but to veteran developers, this is their routine work and they can show you different ways of doing that.In this post, we will introduce two major ones used frequently by developers.git resetgit revertWhat are their differences and corresponding use cases? We will discuss them ...
105,465 14 GIT GIT RESET GIT REVERT
Fix SSL 'alert protocol version' issue while git clone remote repository
Git provides ways to securely connect to remote repository and clone remote repository to local machine. This post will teach you how to fix the "SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version" issue while cloning a remote repository.The issue would look like:If this error occurs, it is most probably caused by out of date git version being used.To improve its security awareness, some weak cryptographic algorithms have been disabled and all git clients should upgrade to latest ones to accomodate to the new security requirements. In the above error case, you should first check what git vers...
8,307 0 GIT GIT CLONE GIT SECURITY