GIT¶
Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.
# config
git config --global user.name "R3D4L1T"
git config --global user.email "redalit@proton.me"
# start
git init # on the workspace
git branch -m main # change the master by main
# create file .gitignore (format ==> **/fileForIgnore)
git add .gitignore
git commint -m "the gitignore has upload"
git stash # create a temporal commit
git stash list # show the temporals commits
git stash pop # resume work on the file
git stash drop # delete stash
# upload files for committed
git status # show the comits
git diff # observe changes
git add file.file # add a file to be committed
git add . # add all
# to be comminted
git commit -m "this is my first commit" # insert and saved commit
git log # show the commits
git log --graph # show in tree format
git log --graph --pretty=oneline # show in oneline
# to do alias
git config --global alias.nameOfAlias "log --graph --decorate --all --oneline"
git nameOfAlias
# move other git branch
git checkout file.file # reset changes in the file to the last saved commit
git reset # to back to the last commit and deleted
git checkout ID # move to other logs with ID of logs
git checkout HEAD # back to the last commit
git reset --hard ID # move the HEAD to ID commint(delete the commits)
# history
git reflog
git reset --hard ID # move the HEAD to ID commint that has been deleted(recover)
# tags
git tag # observe the all tags
git tag tag1 # create at tag1 to the commit
git checkout tags/tag1 # move to other tags
# branch
git branch login # create new branch with name 'login' in the actual workspace
git switch login # move to 'login' branch
git branch -d login # delete branchs
# merge
git merge main # conbine own branch with 'main' branch
# reintergation of branch
git merge login # reintegration the login 'branch' to mastar branch
# upload to github
# create ssh key
# https://docs.github.com/es/authentication
# add the key to setting of user
ssh -T git@github.com
# git remote
# create a repository in the web
git remote add origin git@github.com:r3d4l1t/repository.git
git clone 'url' # clone the repository of github
git push -u origin main # upload the master branch
git push # upload the commints
git fetch # download all the logs of the github
git config pull.rebase false # add marge config for donwloas the repository
git pull origin main # download all git repository
git pull origin branchname --allow-unrelated-histories # download and force merge
# fork: copy repository other user and create a repository in the personal account for work
# sync fork : sincronize
# pull request
# use gitflow for big projects
- download only an carpet of an repository of GitHub