Git - Working on Existing or Cloned Project

by prashere
GNU/Linux ◆ xterm-256color ◆ bash 661 views

So you have cloned a git based project to work on. This cast will just guide you through how to edit some files on that project, add your contributions, commit and then push it to the main repository.

  1. Navigate to the project directory using cd command.
  2. You are making some changes to a file and saving it.
  3. You have tell git that, you have made some changes, so you have to add and then commit you changes with git. You can use git status command to check now and then.
  4. By the time you are editing this file, there is a very high chance that someone is also editing the same file and have pushed new changes to the main repository.
  5. If you try to push, it will say, git cannot push the changes since there are new changes on the repository, which you have pull first.
  6. So it is always a best practice to pull the changes first before pushing your changes.
  7. You can use git pull and the branch name to pull the changes.
  8. If there are any new updates, it will be synced with your local project along with your changes.
  9. While pulling there is also a chance that you and someone else edited the same line in the same file. In that case it is called ‘conflict’. That is git is now confused. It doesn’t know which change it should keep / delete. So it will ask you to resolve the conflict manually. In this cast, you won’t find any conflict and so we are not dealing with it right now.
  10. Final step is to push your changes to the main repository.

-> You edit a file -> git status -> git add -u -> git commit -m “Some meaningful description about the changes you made” -> git status -.> git pull –rebase origin -branchname- -> git push origin -branchname-