8000 GitHub - juzeppejostko/git-bash-commands: This repository is to learn how to work with the branches in git
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

juzeppejostko/git-bash-commands

Repository files navigation

Here are some basic bash and git commands

  1. How can we move to a directory which consists of two and more words?
    Solution: use quotes or "/" symbol
    cd "Program Files"
    or
    cd Program\ Files
  2. How to create a new folder?
    use mkdir command
    Example: mkdir Newfolder
  3. After moving to the target directory we should create 'README.md' file
    echo "This is the description of my project" > README.md
  4. Then we should initialize git:
    git init
  5. Add a file to the repository or all files in the folder
    git add README.md or git add .
  6. Associating the repository on a remote server with the repository in current folder:
    git remote add origin https://github.com/**address
    or
    git remote add upstream
  7. To create new branch with the name "bash" use:
    git branch bash
  8. Switch to this new branch:
    git checkout bash
  9. Push new branch:
    git push -u origin branchname
    or
    git push -u origin HEAD if you are in target branch
  10. To synchronise our fork with the original repository
    git pull upstream master or git pull upstream
  11. Run bash scripts
    To run ".sh" file use next commands:
    chmod u+x hello.sh
    ./hello.sh
  12. Every time to update current branch we use next commands:
    git add . # to update all files
    git commit -m "What was changed"
    git push -u origin branchname///
  13. Bash logical operators:
    'Equal' is -eq
    'Not equal' is -ne
    'Less then' is -lt
    'Less then or equal' is -le
    'Greater then' is -gt
    'Greater then or equal' is -ge
  14. How to reset to a previous/specific commit:
    I. Copy SHA code of target commit
    II. git reset --hard 56e05fced #where 56e05fced is your sha
    III. git commit -m "Revert to 56e05fced"
  15. Rename files in bash:
    mv [options] source_file destination_file
  16. Standard git workflow:
    git pull
    git branch
    git checkout
    git add file | git add .
    git commit -m "comment"
    git push -u origin | git push -u origin HEAD
  17. Merge branch into master:
    git pull origin master
    git merge test
    git push origin master
  18. How to Delete a Git Branch Both Locally and Remotely
    // delete branch locally
    git branch -d localBranchName
    // delete branch remotely
    git push origin --delete remoteBranchName
  19. How to cancel all chenges in current commit:
    git reset
    git checkout .
    git clean -fdx

About

This repository is to learn how to work with the branches in git

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0