GIT quick reference and Error fix.

(522 hits) 06 May 2022 in Web Development by Dario L. Mindoro


* Uploading project to Github
1. git init           <- go to your project folder and initialize git
2. git add .          <- this will stage all your files
3. git commit -m "adding all files"     <- do your first commit to confirm all your files
4. git remote add origin https://github.com/username/repo_name.git  <- set your repo as the remote origin, make sure you already created this at first
5. git push origin master   <- push the files to Github on the master branch

* Always display current branch name on command line prompt

This will easily inform you of what is the current active branch you are working on

nano ~/.bashrc  <- edit your .bashrc file on your home folder

Add these code under the user function area

parse_git_branch() {
 git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}

export PS1="\[\033[00m\]\u@\h\[\033[01m\] \w\[\033[32m\]\$(parse_git_branch) \[\033[00m\]$ "

* Empty commit

Useful if you want to create a pull request without any code changes in case you want to create a new repo base off the master which will be the base of your sub-repository

git commit --allow-empty -m "make pull request"

* Github now require ECDSA
If you got ERROR: You're using an RSA key with SHA-1, which is no longer allowed. Please use a newer client or a different key type.
use this when generating SSH key on your local machine for Github access

ssh-keygen -t ecdsa -b 521 -C "[email protected]"

* Error 403 Forbidden when push to origin

When you get this error while pushing to origin, please check your git config. at .git/config  replace the url value with ssh link

[core]
	repositoryformatversion = 0
	filemode = true
	bare = false
	logallrefupdates = true
[remote "origin"]
	url = https://github.com/username/repo_name.git  <- replace this with ssh version. [email protected]:username/repo_name.git
	fetch = +refs/heads/*:refs/remotes/origin/*




Tagged in : Linux, Php

avatar
Author :
Dario L. Mindoro

Author of Mindworksoft.com, Full-stack developer, interested in media streaming, automation, photography, AI, and digital electronics.