- 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 - How to create a new folder?
use mkdir command
Example: mkdir Newfolder - After moving to the target directory we should create 'README.md' file
echo "This is the description of my project" > README.md - Then we should initialize git:
git init - Add a file to the repository or all files in the folder
git add README.md or git add . - 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 - To create new branch with the name "bash" use:
git branch bash - Switch to this new branch:
git checkout bash - Push new branch:
git push -u origin branchname
or
git push -u origin HEAD if you are in target branch - To synchronise our fork with the original repository
git pull upstream master or git pull upstream - Run bash scripts
To run ".sh" file use next commands:
chmod u+x hello.sh
./hello.sh - 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/// - 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 - 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" - Rename files in bash:
mv [options] source_file destination_file - 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 - Merge branch into master:
git pull origin master
git merge test
git push origin master - 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 - How to cancel all chenges in current commit:
git reset
git checkout .
git clean -fdx
-
Notifications
You must be signed in to change notification settings - Fork 0
juzeppejostko/git-bash-commands
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
This repository is to learn how to work with the branches in git
Topics
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published