Handling/SWinfastructure/git/index
Git Commands
add remote repository
git remote add origin git@github.com:username/new_repo
git push -u origin master
Basic commands
git add {file}
add some file
git commit -m ""
make commit
git push
push it to repository
Brench is sequence of commits. To list all branches
git branch
Branches allow to work with parallel versions of repository, while each one is working indepently. Creating new branch by command (this branch will start from actual commit, we can change actual commit with git checkout):
git branch <name of new branch>
Merging branches can be done using command (this will merge the branch with branch curently using):
git merge <branch name>
Branch can be deleted using command:
git branch -d <branch name>
To see diferences between to files in different bracnhes, this command can be used:
git diff
Tags are special ways how to mark important commits. They can be listed by:
git tag
Tags are divided into two types, lightweight and annotated. The first one is branch like, serves as link to commit. The second one is object including all informations like commit. These tags can be created by (for annoted tag is -m important):
git tag LightTag
git tag -a AnnotatedTag
-m “Creation of annoted tag”
To move between commit git checkout is used. It refresh working space correcponding to selected commit. On this place, new brachnes, tags or commits can be created or changed. To get back after finishing the work, one can get back to top master by:
git checkout master
Show commit history.
git log
Show last commit.
git show
Stash the changes in a dirty working directory away. Use git stash when you want to record the current state of the working directory and the index, but want to go back to a clean working directory. The command saves your local modifications away and reverts the working directory to match the HEAD commit.
git stash
How to use .gitignore.
.gitignore file must be created in main repository.
Before pushing, this command might be used (dont know why at this moment, but it works).
git rm -r --cached .
After this, standard add, commit and push commands are called.
This is how to make merge after merge request already exists
Step 1. Fetch and check out the branch for this merge request
git fetch origin
git checkout -b "0121SWreconstr2ndwave" "origin/0121SWreconstr2ndwave"
Step 2. Review the changes locally
Step 3. Merge the branch and fix any conflicts that come up
git fetch origin
git checkout "master"
git merge --no-ff "0121SWreconstr2ndwave"
Step 4. Push the result of the merge to GitLab
git push origin "master"