Sunday, October 2, 2016

Git


  • First go to the relevant folder and initialize a Git repository , type the following command:     git init
  • To see what the current state of our project is: git status
  •  To add files to the staging area : git add .
  • Let's run git status again to see where we stand 
  • To store our staged changes we run the commit command with a message describing what we've changed : git commit -m "Message"
  • there's git log. Think of Git's log as a journal that remembers all the changes we've committed so far, in the order we committed them : git log
  •  To push our local repo to the GitHub server we'll need to add a remote repository : git remote add origin https://github.com/try-git/
  • So let's push our local changes to our origin repo (on GitHub) :  git push origin master
  •  We can check for changes on our GitHub repository and pull down any new changes by running :git pull origin master
  • In this case we want the diff of our most recent commit, which we can refer to using the HEAD pointer : git diff HEAD
  • run git diff with the --staged option to see the changes you just staged : git diff --staged
  • You can unstage files by using the git reset command : git reset octofamily/octodog.txt
  • Files can be changed back to how they were at the last commit by using the command: git checkout -- <target>. Go ahead and get rid of all the changes since the last commit for octocat.txt : git checkout -- octocat.txt
  • create a branch called clean_up : git branch clean_up
  • You can switch branches : git checkout branch_name
  • We're already on the master branch, so we just need to tell Git to merge the clean_up branch into it : git merge clean_up
  • You can use git branch -d <branch name> to delete a branch : git branch -d clean_up
  • All that's left for you to do now is to push everything you've been working on to your remote repository : git push

No comments:

Post a Comment