Skip to content

git help

Karthigeyan Illancheran edited this page Mar 15, 2019 · 2 revisions

SSH

Generate key

ssh-keygen -t rsa -b 4096 -C "karthigeyan.illancheran@nokia.com"

Add key

ssh-add -K ~/.ssh/id_rsa

force reset fork

git fetch upstream
git checkout master
git reset --hard upstream/master  
git push origin master --force

point submodules to private fork

git submodule deinit -f -- Libraries/NUKit/
rm -rf .git/modules/Libraries/NUKit/
git rm -f Libraries/NUKit/

git submodule add git://github.com/killanch/nukit.git Libraries/NUKit

Delete branch

Remote: git push origin --delete vspk-update-6
Local: git branch -D vspk-update-6

Submodule update

git submodule init
git submodule update
cd Libraries/NUKit/
git fetch
git merge origin/master

Clone only submodules

git submodule update --init --recursive


Delete local/untracked files

Step 1 is to show what will be deleted by using the -n option:

git clean -n

Clean Step - beware: this will delete files:

git clean -f


Create branch from tag

git checkout -b SecPolicySearchBetfair release-4.0.10


List conflicts

git diff --name-only --diff-filter=U


Revert all local changes

git reset --hard


Revert local commit

git reset HEAD~1


Merge branches

git clone -b feat-vnf --recursive git@github.mv.usa.alcatel.com:mlamacch/vsd-architect.git

git remote add fork git@github.mv.usa.alcatel.com:ikarthik/vsd-architect.git

git remote -v

git fetch fork

git merge fork/EgressFwdingPolicy


resolve merge conflicts - choose incoming source

git checkout --theirs Resources/ForwardingSecurityPolicyEntryTemplates.xib


cherry-pick

git clone --recursive -b r4.0 git@github.mv.usa.alcatel.com:CNA/CNA-Server.git

git log => to identify the commit id

git checkout r4.0

git checkout -b VSD-XXX

If not a squash commit:

git cherry-pick 75af506986bdf39753b8d08aff5d16ad188c5717 -m 1

If squash commit:

git cherry-pick 75af506986bdf39753b8d08aff5d16ad188c5717

git push origin VSD-XXX


Reset local with remote contents

git fetch origin

git reset --hard origin/PROD-4743


Reset branch VSD-19901 to an earlier commit 99af8b42448f9d103962e49d825d5f67d462a722

git checkout -b testRevert 99af8b42448f9d103962e49d825d5f67d462a722

git branch -M VSD-19901 VSD-19901-temp

git branch -M VSD-19901

git push -u origin VSD-19901 --force


Diff between branches

git diff --name-status master..vsdmed2 -> difference between master and vsdmed2 branch


remote add upstream

git remote add upstream git@github.mv.usa.alcatel.com:CNA/CNA-Server.git

git remote add upstream https://github.com/nuagenetworks/vsd-react-ui.git


git checkout master -> switch to master branch context


git pull upstream master -> pulls latest changes from repos master to fork master


git push origin -> push latest updates to remote fork master


git checkout VSD-9056 -> switch to PTS branch


git merge master -> from fork master to PTS branch


git push origin -> local PTS branch to remote PTS branch


git clone --recursive git@github.mv.usa.alcatel.com:Architect/vsd-react-ui.git