Showing posts with label GitHub. Show all posts
Showing posts with label GitHub. Show all posts

Sunday, February 15, 2026

git patch automatic code replacement in repository

git show commitID -- folder/ >> 001commitID.patch

cd to fresh git repo without changes and

git apply 001commitID.patch

git format-patch -10 --author="YOURNAME" // look 10 commits and creat separate patch files

git apply ../0001-your.patch

git log -p // full commit history with code changes (the patch/diff output) for each commit

Saturday, February 14, 2026

GitHub hide and change mail in project repository files

git config --global user.name "USER"

git config --global user.email "123456789+USER@users.noreply.github.com"


git config --global --list

git config --local --list


Make sure working tree is clean:

git status


git add .

git commit -m "commit comment"


git filter-branch --env-filter '

export GIT_AUTHOR_EMAIL="123456789+USER@users.noreply.github.com"

export GIT_COMMITTER_EMAIL="123456789+USER@users.noreply.github.com"

' -- --all


rm -rf .git/refs/original

git reflog expire --expire=now --all

git gc --prune=now --aggressive


git log --reverse --format="%h %an <%ae>"

If you see:

yourname@users.noreply.github.com


git filter-branch --env-filter '

export GIT_AUTHOR_EMAIL="1123456789+USER@users.noreply.github.com"

export GIT_COMMITTER_EMAIL="123456789+USER@users.noreply.github.com"

' -- --all


git log


⚠️ This replaces the online repo history:

git push --force --all

git push --force --tags


git log


git log --all --author="yourname"

git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d

git stash clear

git reflog expire --expire=now --all

git gc --prune=now --aggressive


What others must do (if anyone cloned). They must reclone, or:

git fetch --all

git reset --hard origin/main


git log --all --author="yourname"

SHOULD SHOW NOTHING

Wednesday, September 21, 2022

gitignore not working or remove untracked files in git

git rm -r --cached .

git add .

git commit -m "untrack files contained in the .gitignore file"

git reset HEAD . // cancel all commits

git reset --hard

git clean -n

git clean -d -n

https://linuxize.com/post/how-to-remove-untracked-files-in-git/

Monday, September 19, 2022

Show changes in specific file using git

git show filename // will show the log message and textual diff

git status -s // list modified files

git diff filename

git log --follow filename // list commits only

git log --follow -p -- filename // entire history of file modifications

git blame <filename> // show who changed file

Friday, August 26, 2022

git branch is behind master

git pull origin master

git push origin branch-name

git checkout master

git merge new

git checkout -b <branch-name> // create a branch and switch to the branch

git branch <branch-name> // create a branch only

https://git-scm.com/docs/git-branch



git status

git diff

git diff --stat

git add . // add all files in working directory

git commit -m "Your awesome message"

git push origin master

git checkout master

git rebase release // To base master on release
“Take my commits on master, temporarily remove them, fast-forward master to release, then replay my commits on top.”

Wednesday, September 15, 2021

git basics adding project to GitHub

git config --global user.name "Your Name"

git config --global user.email "123456789+yourname@example.com"

git config --list


cd /path/to/your/project

rm -r .git

git init // all files in working directory

git remote add origin https://github.com/your-username/your-repo.git

git remote -v

git remote set-url origin https://github.com/your-username/your-repo.git

git remote -v

https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens

Settings > Developer Settings > All repositories

https://docs.github.com/en/get-started/git-basics/managing-remote-repositories#switching-remote-urls-from-ssh-to-https

git branch -M master         # Rename current branch to 'main'

git push -u origin master    # Push local code and set upstream to 'main'

Username for 'https://github.com':

Password for 'https://OWNER@github.com':

branch 'main' set up to track 'origin/main'.

Everything up-to-date


git add . // add all files in working directory

git commit -m "Your awesome message"

git status

git push origin master


git reset --soft HEAD~1 // cancel 1 last commit

git reset HEAD . // cancel all commits

git reset --hard // deletes files in project folder

git clean -fd

git rm -r --cached .


git status  

On branch master

nothing to commit, working tree clean

git rebase --abort

git remote -v

git checkout -b currentbranchname // exit current branch

Already on 'a'

git checkout -b anotherbranchname // switch to another branch

Switched to branch 'b'

git push origin branchname

git push -u -f origin branchname

-u switch makes the remote GitHub repo the default for your existing project

-f switch forces Git to overwrite any files that already exist on GitHub

error: Your local changes to the following files would be overwritten by checkout:

git checkout -f branchname


git config -l

git config --edit

git config --global --edit

git init -b branch-name

git repo create project-name


git pull --set-upstream origin branch-name

git add . && git commit -m "initial commit" && git push

git push --force origin HEAD: branch-name

npm deploy React App to GitHub

package.json

"homepage": "https://USERNAME.github.com/my-app"

"scripts": {

"predeploy": "npm run build",

"deploy": "gh-pages -d build"

}


git init

git remote add origin git@github.com:USERNAME/my-app.git

npm run deploy //=== yarn deploy

git add . //=== git add -A

git commit -m "Your awesome message"

git push origin master