git config
Use global configuration with --global
flag.
$ git config --global https.sslBackend openssl
$ git config --global https.sslVerify false
$ git config --global http.proxy http://<user>:<password>@<domain>:<port>
$ git config --global https.proxy https://<user>:<password>@<domain>:<port>
In root path of project, run:
$ git init
$ git add .
$ git config user.email <email to login in git repository>
$ git commit -m "a message"
$ git remote add <origin> https://<user>:<password>@domain/<user-owner>/<repositoryname>.git
or to SSH authentication
$ git remote add <origin> git@domain-<ssh-filename>:<username>/<repositoryname>.git
$ git push -u origin master
$ git rm -r <path>
$ git rm <path>
$ git branch <branchname>
To create a new branch with only the last commit...
$ git checkout --orphan <branchname>
So make git add
; git commit
...
$ git checkout <branchname>
$ git checkout -b <branchname>
$ git checkout -b <branchname> <version>
$ git branch
$ git branch --set-upstream-to=origin/<branchname>
$ git push origin <branchname>
Branches are importants to organization of the project. When creating a new feature, fixing a bug, or make a refactoring we should do that in a new branch following the below steps.
To merge the changes from a remote repository, just run:
$ git pull
To update local changes, setup the branch you want to update, and run:
$ git rebase <from-branchname>
In conflict case solve it (you must to commit the changes), so run:
$ git rebase --continue
So solve the next conflict. If there are no new conflicts, commit and push the new changes to remote repository.
If something goes wrong, come back running:
$ git rebase --abort
$ git cherry-pick <commit-hash OR branch-name> --no-commit
So just run $ git push
.
Note: to put a interval, run $ git cherry-pick <commit-hash-START>..<commit-hash-END>
.
$ git push --delete origin <branchname>
$ git branch -d <branchname>
$ git diff <filename>
$ git tag <value>
$ git push origin <tag>
Note: tag’s content can’t be changed.
$ git tag -d <tag>
$ git push --delete origin <tag>
$ git reset --hard HEAD~1
$ git revert <"HEAD" or commit hash>
$ git push
- clone the project;
- ceate a new origin;
- create and checkout to a new branch;
When you finish:
- commit the changes;
- checkout to main branch;
- update the main branch from branch you worked for;
- make "Pull Request" through main branch.
Sources: