Git commands for a beginner

Git commands for a beginner

if you are beginner in git environment then you should know that git provides you a way to update the file and move you file from local server to live server with command line

Like a beginner you have installed git on your server and setup the git account and ready to use git

Now here is the problem begin where to start and how to use command
Like you can check in which branch you are working
Example: server-localhost(master): So master is your current branch
Now you made some changes in file and you want to push it on live server

So keep in mind before push any code on live server you need run pull command on same branch
after changes you need you pull file from server
Example:
git pull origin master

This command will fetch update file from live server to your local server but will not change your changes in files

Now you need to add your changes on git
run command to add all changed file to add in git queue
git add .

This command will add all your changed file in a queue of git to commit
Now you need to commit the changes on server
run this command
git commit -m "changes in files to commit for beginner"

-m denotes message for commit

Now once you have committed the changes then you can push those changes on live server.
now run this command
git push origin master

This command will push all your local changes on live server

Comments