At the beginning we must initialize out repo. Let's say it have tempo name. For now we guess that repo was created on git server and we only must create a local copy on our development machine. First of all we must install git client. Further i will talk about linux console version of client. On the next step we must initialize our local repo:
- git init
- git add <file1> <file2> ...
- git commit -m "init commit"
- git remote add origin git@remoterepo.host.addr:username/path/to/tempo.git
- git push -u origin master
git remote add remote_name remote_locationAlso we have git clone with similar format:
git clone remote_locationYou can ask, what the difference between "remote add" and "close" and i answer you:
- remote add - creates an entry in your git config and you can either push changes to remote repo
- clone - creates new repo (local copy from remote_location). It similar to this code:
git init
git remote add origin remote_location
git pull origin masterNow let's talk about work with branches. First of all you need to create one by command:
git branchAfter that you can view branches:
git branch - show your local branches
git branch -a - showing all branches including remote onesWhen our new branch was founded in list - we can switch to it:
git checkout <branchname>After work on it - we can remove it
# delete local
git branch -d <branchname>
# remote
git push origin :<branchname>We can push changes to remote branch after committing:
git push origin <branchname>:refs/heads/<branchname>When work on branch was finished - it can pushed to master:
git checkout master
git merge <branchname> --no-ff
git push origin master - push master branch to remote repoIf you need update code from remote repo:
git remote update; - update all remote repos
git pull <remoterepo> <local>