Monday, 9 November 2015

How to use Git with steps

  1. At first go to the folder in which  using "cd .." and "cd [folder-name]". If you have used in similar way in command prompt, then you don't be guided about the first step.
  2. To first initialize, use "git init"
  3. Then, to check the untracked files, use "git status"
  4. Now, add the files into the tracked ones using "git add [file-name]", if you have not any files in the folder, then you will have to create one and then add.
  5. Use "git commit -m [Message]" to confirm with the message to identify what you are doing.
  6. Create a github account and create a repository there. Now that repository would have a link like https://github.com/[Username]/[Repository-Name].git
  7. Its to time to type the command "git remote add origin [Link-of-the-git]".
  8. Next, push it to cloud using command "git push origin master"
  9. A prompt will appear to type the username and password. Next your files will be the clouded in the desired repository.

 Once I was using "git push origin master" to push  my new update work. But an error was coming:

error: failed to push some refs to 'https://github.com/rajatraj733/firefox-extension.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

http://stackoverflow.com/questions/24114676/git-error-failed-to-push-some-refs-to
Then, I used the above mentioned link to rectify the error. What I did was:-
  1. 1st command: git pull --rebase origin master
  2. 2nd command: git push origin master
And it worked. Sometimes I think what would have happened to the so called developers, had stackoverflow.com not ever started.

By the way, I will explain these things like why such errors happened, later so that I could know the principle of github.

No comments:

Post a Comment