git
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| git [2011/07/21 16:51] – k2patel | git [2020/08/10 02:35] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== GIT Repository ====== | ====== GIT Repository ====== | ||
| + | |||
| + | ==== Setting up GIT ==== | ||
| + | === Create Server === | ||
| + | == Define User == | ||
| + | <code bash> | ||
| + | git config --global user.name " | ||
| + | git config --global user.email " | ||
| + | </ | ||
| + | |||
| + | == Create location for Repository == | ||
| + | <note tip> | ||
| + | <code bash> | ||
| + | mkdir -p / | ||
| + | cd / | ||
| + | </ | ||
| + | |||
| + | == Create bare repository == | ||
| + | <code bash> | ||
| + | git --bare init | ||
| + | </ | ||
| + | |||
| + | === Initial Synchronize with client === | ||
| + | == Initializing commit == | ||
| + | <note tip> | ||
| + | <code bash> | ||
| + | cd / | ||
| + | git init | ||
| + | git add . | ||
| + | git commit -m " | ||
| + | </ | ||
| + | |||
| + | == Define server and push files == | ||
| + | **For Local** | ||
| + | <code bash> | ||
| + | git remote add origin / | ||
| + | git push origin master | ||
| + | </ | ||
| + | |||
| + | **For Remote** | ||
| + | <code bash> | ||
| + | git remote add origin ketan@reposerver:/ | ||
| + | git push origin master | ||
| + | </ | ||
| ==== Backup ==== | ==== Backup ==== | ||
| Line 21: | Line 64: | ||
| <code bash> | <code bash> | ||
| cd ~/test.git | cd ~/test.git | ||
| - | git remote add backups | + | git remote add backup |
| - | git push backups | + | git push backup |
| cat .git/config | cat .git/config | ||
| </ | </ | ||
| Line 67: | Line 110: | ||
| done | done | ||
| </ | </ | ||
| + | |||
| + | ==== Git reset local ==== | ||
| + | **following command can be used for following purpose :** \\ | ||
| + | To discard all local changes and restore it to the remote repository.\\ | ||
| + | When you have error //Your branch is ahead of ' | ||
| + | <code bash> | ||
| + | git reset --hard origin/ | ||
| + | git pull | ||
| + | </ | ||
| + | |||
| + | ===== Git Submodule ===== | ||
| + | |||
| + | ==== Clone Repository including submodule ==== | ||
| + | |||
| + | <code bash> | ||
| + | git clone --recursive git@github.com: | ||
| + | </ | ||
| + | |||
| + | ==== clone submodule from existing project ==== | ||
| + | |||
| + | <code bash> | ||
| + | git submodule update --init --recursive | ||
| + | </ | ||
| + | |||
| + | ==== To initialize single submodule ==== | ||
| + | <code bash> | ||
| + | git submodule update --init modules/ | ||
| + | </ | ||
| + | |||
| + | ==== Pull changes from all submodule ==== | ||
| + | <code bash> | ||
| + | git submodule foreach git pull origin master | ||
| + | </ | ||
| + | |||
| + | ==== Usefull when submodule HEAD and status HEAD messed up ==== | ||
| + | <code bash> | ||
| + | git submodule update --init | ||
| + | </ | ||
| + | |||
| + | |||
| + | |||
git.1311267110.txt.gz · Last modified: 2020/08/10 02:30 (external edit)
