marcpre / learning_git

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Learning git

Get repository name

git remote show origin Get repository name

Add remote

git remote add origin https://github.com/user/repo.git

Add a remote

My username is not linked

First, run git config -l to check your settings and make sure that you don't have something unexpected in there.

Use git config --global user.email correct-email@example.com and git config --global user.name marcpre to change the username

Stackoverflow - Username is not linked

Execution Path of Git

git --exec-path

Adding remote repo

  1. add & commits
  2. git git remote add origin "remote_repo_url"

Github - Adding an existing project

Rebaseing

git rebase

Rebasing is the process of moving or combining a sequence of commits to a new base commit. Rebase has a powerful history rewriting features. The primary reason for rebasing is to maintain a linear project history. For example, consider a situation where the master branch has progressed since you started working on a feature branch.

Resync git repo with new gitignore file

Save Username/Password

git config --global credential.helper store
git pull origin master

Stackoverflow - Save username/pwd

Resync gitignore file

# rm all files
git rm -r --cached .
# add all files as per new .gitignore
git add .
# now, commit for new .gitignore to apply
git commit -m ".gitignore is now working"

Stackoverflow - Resync gitignore file

Create Release

  1. On GitHub, navigate to the main page of the repository.

  2. Releases tab Under your repository name, click Releases.

  3. Releases draft buttonClick Draft a new release.

  4. Releases tagged versionType a version number for your release. Versions are based on Git tags. We recommend naming tags that fit within semantic versioning.

Github - Create Release

Replace false author

git filter-branch --env-filter 'if [ "$GIT_AUTHOR_EMAIL" = "incorrect@email" ]; then
     GIT_AUTHOR_EMAIL=correct@email;
     GIT_AUTHOR_NAME="Correct Name";
     GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL;
     GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"; fi' -- --all

Stackoverflow - Email Change

Commit History

git log

Show commit history

Errors

"Cannot read property 'resourceUri' of undefined"

Add the folder manually with git add folderName/

Github VSCode Thread

"The current branch master has no upstream branch"

git push -u origin master

Stackoverflow

"LF will be replaced by CRLF"

git config core.autocrlf false --> under Windows

Stackoverflow

"Git refusing to merge unrelated histories"

git pull origin master --allow-unrelated-histories

Stackoverflow

fatal: refusing to merge unrelated histories

git pull origin master --allow-unrelated-histories

Stackoverflow