- github fork workflow ( using vscode )
- rename branch
- checkout a remote branch
- graphical diff
- graphical diff ( code )
- diff from previous commit
- undo last commit
- commit all staged files
- clone specific tag
- show local changes
- show commit logs
- change to another branch/commit
- revert a commit
- pick a commit
- pick some file from another commit
- discard all local changes
- tag specific commit and push to remote
- github tips
- show branches tree
- show local branches
- commit to a new branch
- merge a branch into current
- delete branch local and remote
- rename branch local and remote
- pull and switch to a branch
- add submobule
- submobule init
- reset head on remote
- skip changes from already added file
- restart track changes for already added file
Don't fork a project until you made some effective changes locally to the original cloned repository, instead:
- clone project which you want to contribute
git clone REPO_URL- make changes locally and test them
- create a branch named ( eg.
fix-some) withSource Control / Branch / Create Branch...or
git checkout -b fix-some- commit changes to your local branch
- FORK the project using github btn then copy your forked repository url ( MY_ORIGIN ) to clipboard
- add your origin from
Source Control / More Actions / Add Remote...( paste your fork url then insert a namemy) - push changes to your repo
Source Control / Push( this will ask you to choose an origin as upstream of the branchfix-some, then choose your fork originmy) - go to github on your forked repository and click
Compare & pull requestbtn
sometime you need to import a local git repo to a remote where the default branch differs in the name, ie. local is master while in remote is main; to overcome this issue rename the branch before push
git branch -M mainif remote not available adds ( REMOTENAME could "original" if you working on a fork and wants to add the original one )
git remote add REMOTENAME URLthen fetch the branch you need
git fetch REMOTENAME TAGfor a list of branches available locally use git branch -a
then checkout remote branch
git checkout -b remotes/REMOTENAME/TAGapt install -y diffuseedit ~/.gitconfig
[diff]
tool = diffuse
and optionally to disable confirm open gui
[difftool]
prompt = false
tune ~/.gitconfig
[merge]
tool = vscode
[mergetool "vscode"]
cmd = code --wait $MERGED
[diff]
tool = vscode
[difftool "vscode"]
cmd = code --wait --diff $LOCAL $REMOTE
prompt = false
git diff commitid^!to increase line numbers
git diff -U10 commitid^!for latest commit diff
git diff HEAD^git reset HEAD~commit -a -m "msg"git clone <url> --branch <tag> --single-branchgit diffgit loggit checkout <commit>git revert <commit>this will bring given commit and inject into current HEAD
git cherry-pick <commit>git checkout <COMMIT_SHA> -- filepath1 filepath2git clean -dfxgit tag -a vxxx <commit>
git push --tags- retrieve current page in a permalink form ( hotkey
y)
prerequisite : apt install git-extras
git-show-treegit branchsorted by recent
git branch --sort=-committerdateor tree
git log --graph --pretty=oneline --abbrev-commitgit checkout -b newbranch
git add --all
git commit -a -m "msg"git merge anotherbranchgit branch -d branchnameto delete branch on remote:
git push originname --delete branchnamegit branch -m old-name new-name
git push --set-upstream origin new-name
git push origin --delete old-namegit fetch origin
git checkout --track origin/<branchname>for example follow initialize a submodule for given repo url and branch into local subfolder inside a thirdy folder
mkdir thirdy
git submodule add -b avalonia-pkg-upgrade https://github.com/SearchAThing-forks/CSharpMath.git thirdy/CSharpMathgit submodule update --initor if need to update submodule present in submodule ( use with caution, may not necessary )
git submodule update --init --recursivegit reset --hard SHA
git push origin BRANCH --force- refs: https://www.abrahamberg.com/blog/git-remove-commits-from-branch-after-push-reset-revert-or-rebase/
git update-index --assume-unchanged FILEgit update-index --no-assume-unchanged FILE