git commands tutorial code example

Example 1: git commands

…or create a new repository on the command line
git init
git add .
git commit -m "first commit"
git remote add origin https://github.com/metinkaya1511/FinraDeck.git 
(GitHub’daki adres)
git push -u origin master
…push an existing repository from the command line
git remote add origin https://github.com/metinkaya1511/FinraDeck.git  
(github adresi)
git push -u origin master 
CREATE BRANCH
-   git branch develop ==> it creates new branch named 'develop' but still 
keep being on master branch
-   git checkout develop ==> it will change your branch to the develop branch
git checkout -b develop ==> it creates also a branch named develop and 
switches to it automatically
DELETE
git branch -d <branch_name> deletes the branch. If we have unmerged changes, 
this command gives a warning and does not delete.  
git branch -D <branch_name> deletes the branch even if it has unmerged changes.
Gives no warning.
SWITCH to Branch
git checkout develop checks out the branch, switches to the branch.
git checkout -b <branch_name> creates a new branch and switches to it.  
git merge <branch_name>  this command takes changes from the given branch, 
and merges with the current branches we are on.

Example 2: git commands

git init
git add *Enter File Name Here*
git commit -m "first commit"
git remote add origin *Enter URL Here*
git push -u origin master

Example 3: git basic command tutorial

#Initialize Repo
cd my_awesome_project
git init
#NOTE:you need to setup your global (--global) or project user
git config --global user.name POG
git config --global user.email [email protected]
#Create a README.md and .gitignore file then stage all changes
git add .
#Commit them
git commit -m "Create REAME and gitignore"

Example 4: git commands

If you want to upload your code first check status

//to check how many files contains changes
1. git status

//to add file to the repository
2. git add youFilePath

//if you want to add all file then
3. git add .

//now commit the code
4. git commit -m "anyMessageYouWantToWrite"

//push the code
5. git push

//if you want code from git then
6. git pull

Example 5: git basic commands

git commit -a