- 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
- pull and switch to a branch
- add submobule
- submobule init
- reset head on remote
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 request
btn
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 main
if remote not available adds ( REMOTENAME could "original" if you working on a fork and wants to add the original one )
git remote add REMOTENAME URL
then fetch the branch you need
git fetch REMOTENAME TAG
for a list of branches available locally use git branch -a
then checkout remote branch
git checkout -b remotes/REMOTENAME/TAG
apt install -y diffuse
edit ~/.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-branch
git diff
git log
git checkout <commit>
git revert <commit>
this will bring given commit and inject into current HEAD
git cherry-pick <commit>
git checkout <COMMIT_SHA> -- filepath1 filepath2
git clean -dfx
git tag -a vxxx <commit>
git push --tags
- retrieve current page in a permalink form ( hotkey
y
)
prerequisite : apt install git-extras
git-show-tree
git branch
sorted by recent
git branch --sort=-committerdate
or tree
git log --graph --pretty=oneline --abbrev-commit
git checkout -b newbranch
git add --all
git commit -a -m "msg"
git merge anotherbranch
git branch -d branchname
to delete branch on remote:
git push originname --delete branchname
git 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/CSharpMath
git submodule update --init
or if need to update submodule present in submodule ( use with caution, may not necessary )
git submodule update --init --recursive
git reset --hard SHA
git push origin BRANCH --force