[Security/Gitea] How to Secure Your Public Gitea Server Without Complex Configuration

Last time when I restarted my Gitea server was when I upgraded it to 2.20.11. It has been six months. Although I almost pushed code everyday, I didn’t notice that my Gitea server was already attacked by hackers for a couple of months. I found out that the hackers created few users and repositories on my Gitea server everyday. I was lucky that I found out this issue before it was too late. ...

[Golang] go get: fatal: could not read Username for 'xxx': terminal prompts disabled

1. Error 1: fatal: could not read Username for 'https://github.com': terminal prompts disabled The issue appears when I tried to download a private golang repository by the command go get github.com/oscarzhou/private-helloworld. The completed error shows as below: % go get github.com/oscarzhou/private-helloworld go: module github.com/oscarzhou/private-helloworld: git ls-remote -q origin in /Users/oscarzhou/go/pkg/mod/cache/vcs/c5fb5660c8bfa54f1b957fc4e651ac76f19b939fc9015bf3bcbc21a34c925af7: exit status 128: fatal: could not read Username for 'https://github.com': terminal prompts disabled Confirm the import path was entered correctly. If this is a private repository, see https://golang.org/doc/faq#git_https for additional information. If you have already googled this issue, you may find that most of the answers tell you to configure your git as shown below: ...

[Git] How to configure SSH profile for Github account

There are many benefits for using Git with SSH connection. Do not need to type the password every time when pushing the project. Able to configure multiple git accounts in the same machine without using password every time. For Golang projects that reference other Golang private repositories, SSH connection is must thing. This post will show you how to configure SSH profile for your GitHub account from scratch. I assume that you did not ever configure the Git on your host. To check it, you can run git config --global --list. The expected output should be empty. If it is not, don’t worry, leave it there for now. We can figure it out later. ...

Git Handbook (🚧Continuous Update)

1. Discard the changes git checkout -- . 2. Create a new branch git checkout -b <branch_name> # or git branch <branch_name> 3. Cache the password git config --global credential.helper store git config --global credential.helper cache 4. Stash the current changes git stash 5. Recovery/Apply the stash to the current branch git stash list git stash apply stash@{stash_index} # Most often we recover the stash@{0}, so we also can use below git stash apply 6. Configure username and email locally Sometime we need to configure a different username and email for the specific repository ...

[Git] Unable access xxx: Is a directory

When I run git status, it shows the below error warning: unable to access '/etc/gitconfig': Is a directory warning: unable to access '/etc/gitconfig': Is a directory warning: unable to access '/etc/gitconfig': Is a directory The solution is to remove /etc/gitconfig. The target /etc/gitconfig might be varied from each case. With the below command, all can be solved. sudo rmdir /etc/gitconfig The reason that the problem suddenly pops up is because I ran a experiment docker command something like docker run --rm -v /etc/gitconfig:/etc/gitconfig ..... So the /etc/gitconfig is created. ...

[Git] Error: remote rejected (permission denied)

The error pop up When I pushed the changes on a new branch for the first time. ! [remote rejected] oscar-next -> oscar-next (permission denied) error: failed to push some refs to 'https://github.com/oscarzhou/portainer.git' The solution is to update the git config like below git config --local --list # old config remote.origin.url=https://github.com/oscarzhou/bar.git # update new config with git config remote.origin.url https://foo%40gmail.com@github.com/oscarzhou/bar.git After that, we can run git push --set-upstream origin <branch_name>

[Git] Fatal: this operation must be run in a work tree

fatal: this operation must be run in a work tree The error pop up while running git status. The solution is to change the repository not bare mode git config core.bare false

[Git] How to rebase the pushed branch

Learning the knowledage with a real case is always perferred. I met a case today that I need to use git rebase --interactive to solve the issue. The story is that my colleague created a branch for doing some research one year ago. Let’s say the branch name is feat/performance-research. As the branch is mainly for research purpose, it was not merged to the master branch at that time. However, some changes and results were quite valuable. ...

[Git] How to work with remote repository (with example)

When we manage and maintain a public github repository, it is common to see a case that a fixed branch from outside contributor’s is staled. The reasons can be The github repository owner/maintainer and contributor did not actively process the issue in time. The contirbutor only commited the changes in his branch but didn’t make a pull request, and after a period, he is not reachable. Other reasons… Overall, it is not easy to maintain a public github repository, especially the one with lots of stars. This post will show a way to solve the above issue with a git feature. ...

[Git] How to ignore the commited file

In Git, we can ignore to track of a file or folder by adding their paths into the file .gitignore. However, sometimes we could mistakenly commit and push file and folders that are not needed to be tracked by Git. In such case, .gitignore will be not working. The issue can be solved by the below steps: Add the file path into .gitignore file. Remove the commited file from the git cache by git rm --cached bar/foo.log Commit the changes by git commit -m "xxx" After executing the above steps, you can see the file bar/foo.log is still there but will be not tracked by Git. ...

DigitalOcean Referral Badge
Sign up to get $200, 60-day account credit !