-
Notifications
You must be signed in to change notification settings - Fork 0
Useful Git commands
git config --global core.editor "vim"
or
export GIT_EDITOR=vim
git config --global user.email "shamik@jamba.com"
git config --global user.name "Shamik"
git config –lgit fetch origin pull/42/head:pr-42
switch to the pr git checkout pr-42 and then install it to check the code by pip install -e .
https://stackoverflow.com/questions/42019529/how-to-clone-pull-a-git-repository-ignoring-lfs
GIT_LFS_SKIP_SMUDGE=1 git clone SERVER-REPOSITORYgit clone https://github.com/username/repository.git /path/to/directorygit clone -b <branchname> <remote-repo-url>git tag -a <any name/version number> -m <any message of choice>
git tag -a sgd-classifier -m "SGDClassifier with accuracy 67.06%"Pushing tags after creating them. Tags aren't pushed with regular commits so they need to be pushed separately
git push origin [branch name] --tags
git tag
git tag -d <tag-name>
git tag --delete origin <tag-name>
If the tag and branch name is the same then:
git push origin :refs/tags/<tag-name>
git rev-list --left-right --count <branch to compare to>...<branch to be compared>
# git rev-list --left-right --count nlp_amplify_master...nlp_amplify_aue131
# Output
# 3 6
# Meaning nlp_amplify_aue131 is 3 commits behind nlp_amplify_master and 6 commits ahead of itgit stash
git stash push -- <file path> <file path>
# git stash push -- common/anlpModels/ESG/ESGModel.py ds/experiments/experiment_process/simulate_gradual_training.pygit stash list
git stash apply `stashnumber`
# git stash apply stash@{0}git stash drop stash@{2}
git stash clear
git stash show <stash> -p > <filepath>
# git stash show stash@{0} -p > ds/patch/possiblepatchgit push -u origin [branch name]
git branch -m <old-name> <new-name>
git push origin -d <old-name>
git branch -d <branch-name>
This deletes the entire commit history and all the changes associated to each commit.
git reset --hard <commit hash>
# or
git reset --hard
# the above resets the branch to the latest commitIf removing commit history is required but by keeping the changes in a staged area
git reset --soft <commit hash>First create the repo on github with the same repo name
git remote add origin https://github.com/shamik/<reponame>.git
git push –u origin mastergit push --set-upstream origin master
"fatal: refusing to merge unrelated histories"
git merge <branch> --allow-unrelated-histories
git rm –r –cached <dir>
git commit –m "some message"git remote –v
# or
git remote get-url <branch name, e.g. origin>git branch –a --contains 55bc284d49b2387865baf06573c8b04584bf4b03
Emptying the current git directory and removing all untracked files recursively across all directories
- Perform a dry run first, -d is for removing directories
git clean –dn - Then clean all the files
git clean - For a specific path
git clean –dn <path>
git log –1
git show -sShowing all the files that are different in a commit, --name-only can be replaced by –name-status to show the status of the different files
git show --pretty="" --name-only <sha1-commit-hash>
git log --pretty=format:"%h - %an, %ar : %s"
git commit --amend
git diff <older commit hash> <newer commit hash> -- <path to the file>
# git diff 355dc53 e92f514 -- feextraction/nlp/processors/granular_concept_extractor.pygit log -p --follow -- <filename>
git lfs install
git lfs clone
git lfs pullgit rm --cached -r .
git reset --hard
git rm .gitattributes
git reset .
git checkout .