Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Git CheatSheet #154

Open
AllanChain opened this issue Dec 9, 2020 · 0 comments
Open

Git CheatSheet #154

AllanChain opened this issue Dec 9, 2020 · 0 comments
Labels
blog: cheatsheet |108686978-1ae51480-7531-11eb-93c7-d201146b237d.jpg @post This is a blog post

Comments

@AllanChain
Copy link
Owner

AllanChain commented Dec 9, 2020

View Post on Blog


Force pull

git fetch
git reset --hard origin/master

Assume unchanged

git update-index --assume-unchanged exam.ple

Upgrade git for windows

git update-git-for-windows

Delete tag

git tag -d tagname
git push --delete origin tagname

Remove submodule

From https://stackoverflow.com/a/1260982/8810271

  1. Delete the relevant section from the .gitmodules file.
  2. Stage the .gitmodules changes:
    git add .gitmodules
  3. Delete the relevant section from .git/config.
  4. Remove the submodule files from the working tree and index:
    git rm --cached path_to_submodule (no trailing slash).
  5. Remove the submodule's .git directory:
    rm -rf .git/modules/path_to_submodule
  6. Commit the changes:
    git commit -m "Removed submodule <name>"
  7. Delete the now untracked submodule files:
    rm -rf path_to_submodule

Split repo

Single File

From https://stackoverflow.com/questions/39479154/how-can-i-split-a-single-file-from-a-git-repo-into-a-new-repo
Use git fast-export.

First, you export the history of the file to a fast-import stream. Make sure you do this on the master branch.

cd oldrepo
git fast-export HEAD -- MyFile.ext >../myfile.fi

Then you create a new repo and import.

cd ..
mkdir newrepo
cd newrepo
git init
git fast-import <../myfile.fi
git checkout

Sub Directory

git filter-branch -f --prune-empty --subdirectory-filter  path/to/module

How to make file +x in Git on Windows?

From https://stackoverflow.com/a/21694391/8810271

git update-index --chmod=+x foo.sh
@AllanChain AllanChain added blog: cheatsheet |108686978-1ae51480-7531-11eb-93c7-d201146b237d.jpg @post This is a blog post labels Dec 9, 2020
github-actions bot pushed a commit that referenced this issue Dec 9, 2020
github-actions bot pushed a commit that referenced this issue Dec 10, 2020
github-actions bot pushed a commit that referenced this issue Dec 13, 2020
github-actions bot pushed a commit that referenced this issue Jan 21, 2021
github-actions bot pushed a commit that referenced this issue Feb 21, 2021
github-actions bot pushed a commit that referenced this issue Feb 28, 2021
github-actions bot pushed a commit that referenced this issue Mar 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blog: cheatsheet |108686978-1ae51480-7531-11eb-93c7-d201146b237d.jpg @post This is a blog post
Projects
None yet
Development

No branches or pull requests

1 participant