This project is designed to guide you throughout the Git and Github project workflow and how to store each commit in a way that whenever required, you can easily rollback and maintain a complete editing history of the project.
Use git init
to create a new repository on your local
storage.
Use git status
to check the current status of repository.
Create file and add some text into it for demonstration
Use git add .
to add content to staging area. Note: you
can replace .
with any file names.
Again edit files and check the status
Use git diff
to check changes made on lines in the files
that are currently staged.
Use git commit -m "COMMIT MESSAGE"
to save and commit
your changes and you can view the commit history using
git log
command
I've made some changes in the file again as shown by current status
Again commit fresh changes
Copy the url of new reposity
Connect remote to local via command
git remote add REMOTE_NAME REMOTE_URL
as shown below.
Use git push REMOTE_NAME BRANCH_NAME
to push local
changes to remote in that branch.
Remote repository containing the changes made on the local repository.
Use git log
to check commit history.
I've made changes from one system and pushed.
Use git fetch origin master
and
git pull origin master
to sync remote changes to local
repo on other system.
Now I've made changes to line 2 from one system and pushed. Also I've changed line 2 on other system. Now, when we try to merge these, it will raise conflict. Here's how to deal with it.
Now it is giving merge conflicts on other machine when i pull remote
changes. Remember, anything between <<<<<<< HEAD
and
=======
is local change and anything between
=======
and >>>>>>> COMMIT_HASH
is upcoming
changes from remote. I want to merge remote so I will delete my own
changes and merge remote changes.
Now if I'm working on a project and want to add a new feature, I won't add it directly to prevent doing harm to previous code. Instead, I will create a new branch and add the new feature to that branch. After I'm sure there's no problem, I'll merge the new branch to master and push it to remote repository to make it available to other developers.
So Now, everything is working fine and previous code is also safe.