Git

| 2 min read

2021-06-27

Git

home/Professional

Pull

usually I try to pull MyObsidian and the error messege says something like:
error: Your local changes to the following files would be overwritten by merge:
here I saw somthing that words for me:

git checkout path/to/file/to/revert
--or
git checkout .obsidian/workspace

Fetch

git fetch -p

git fetch command downloads commits, files, and refs from a remote repository into your local repo
-p Before fetching, remove any local tags that no longer exist on the remote if --prune is enabled.
More about git-fetch

fsck

git-fsck - Verifies the connectivity and validity of the objects in the database
MOre about git-fsck

fix the Git error "object file ... is empty"

find .git/objects/ -type f -empty | xargs rm
git fetch -p
git fsck --full

first row described here

merging some branch from other branch

make sure you are in branch that you don't want to pull. For example if you have master and develop branch, and you are trying to pull master branch then stay in develop branch.

git checkout develop

Then,

git pull origin master

then the changes that has been applied to master will appear also in develop branch

rollback to specific commit

git reset --hard <old-commit-id>
git push -f <remote-name> <branch-name>

rollback to specific commit - after rebase

git reflog

identify the commit that happen before the rebase and you want to rollback to. copy the identifier i.e. HEAD@{12} and:

git reset --hard HEAD@{12}
git push -f <remote-name> <branch-name>

config

I wanted to check the error of the proxy that I didn't success to remove and I didn't know where the config stay (level and so on) so I did:

Finding the configuration
git config --global -l

it returns the configurations of the level global

Remove the section

then, I removed the section of the remote.origin and http (for http.proxy config set):

git config --global --remove-section remote.origin
git config --global --remove-section http

then the same for the system level: git config --system ...

Learn from mistake: DON'T define config other than local level, unless you have really good reason!

List of directories involved on branch

103yakikiAutoB compares to master

git show --pretty="" --name-only $(git log 103yakikiAutoB --not master --pretty=format:"%h")