Local » Remote
Initializing git
environment on the local PC
git init
To initialise the repository in the folder. This will generate .git
file which is a hidden file.
Add files
echo "hello world" > test.txt
#create the `text.txt` file
git add test.txt
#confirm to add new file to `.git`
git commit
#a file pops one, take off the # tag from the file name, then save
git push [remote-address]
#you will see a new file added to your remote repo
git add
can also be used for directory:git add [folder-name]
Basic git command
git status
To check the status
git commit test.txt
Commit the new file ready for push to the origin.
git checkout -b [new-branch-name]
-b
is to create a new branch, then you will be switched to the new branch.
git checkout [existing-branch]
This is to switch between existing branches
git branch
To check which branch are you on
git branch -D [local-branch-name]
To delete local branch
git push origin -d [remote-branch-address]
To delete branch remotely
Note: in case the origin is not set, you may need to use the origin remote address.
git fetch origin
To first fetch what you have in the remote address