Thursday, June 16

Github - Pushing your code to Github

Lets say you have a project you want to upload to github for versioning. You can take following steps to get started.

1) Login to your account in github.com and create a new repository

2) Navigate to your project folder via the command prompt and run
    >> git init
    This will initialize a repository in your file system.

3) Now we need to add all the files into local repository, which will stage it for commit.
    >> git add .
    The "." or "dot" at the end of command is to add all the files in the directory.

4) Next, commit the files and add a message to the commit
    >> git commit -m "Initial Commit"
    Commits the tracked changes and prepares them to be pushed to a remote repository.

5) We are now ready to push the changes of local repository. However, we should first make a pull request so that our local repository is up to date. Usually this step should be taken before we add any files to the repository.
    >> git pull <your_repository_url>

6) If there are no conflicts or issues, you can now push your local repository changes to the remote repository.
   >> git push
   You will be asked for your username and password of github, after successful validation your code will be deployed to github.

Be the first one to Comment!!!

Post a Comment