Basic GitHub Terminal Commands
Create a Project
git init # initializes the repo
git add . # add all files
git commit # commit all changes
git commit -m "new function added" # commit with a message
git push -u origin master # push branch to remote
Working with Existing Repo
git clone <url> # clone repo to local directory
# <url>: https://github.com/enesccinar/xrider_api
Checkout and Coding
I need to separate features, bugfixes or etc. into different branches.
git branch # list the all active branches
git pull # get the latest version of current branch
git checkot <branch-name> # get the latest version of specified branch
git checkout -b <new-branch> # create new local branch. ex: user_login
Merging
git branch --merged # which shows you the branches that you merged with the current branch
git merge <target-branch> # merge branches
Delete
git branch -d <branch-name>
Listing
git branch -a # list all remote and local branches
git branch -r # list remote branches
git show-branch # show branches & commits
Commits
git log origin/<branch-name>..HEAD
git diff origin/<branch-name>..HEAD
# both of these commands show commits which are waiting to be pushed.
Then coding…
When I complete the coding, I need to send them to the GitHub.
git push -u origin user_login # sync local branch with remote