How to use Git?

前端 未结 10 1285
野趣味
野趣味 2020-12-02 04:49

I am an engineering student who spends most of his spare time watching TV rather than coding. So basically I have zero experience with any kind of version control system. My

相关标签:
10条回答
  • 2020-12-02 04:55

    I think gitready is a great starting point. I'm using git for a project now and that site pretty much got the ball rolling for me.

    0 讨论(0)
  • 2020-12-02 04:55

    this is my blog on git and its for beginners who want to get started on git. https://techxposers.com/git-for-beginners/

    0 讨论(0)
  • 2020-12-02 04:56

    Using Git for version control

    Visual studio code have Integrated Git Support.

    • Steps to use git.

    Install Git : https://git-scm.com/downloads

    1) Initialize your repository

    Navigate to directory where you want to initialize Git

    Use git init command This will create a empty .git repository

    2) Stage the changes

    Staging is process of making Git to track our newly added files. For example add a file and type git status. You will find the status that untracked file. So to stage the changes use git add filename. If now type git status, you will find that new file added for tracking.

    You can also unstage files. Use git reset

    3) Commit Changes

    Commiting is the process of recording your changes to repository. To commit the statges changes, you need to add a comment that explains the changes you made since your previous commit.

    Use git commit -m message string

    We can also commit the multiple files of same type using command git add '*.txt'. This command will commit all files with txt extension.

    4) Follow changes

    The aim of using version control is to keep all versions of each and every file in our project, Compare the the current version with last commit and keep the log of all changes.

    Use git log to see the log of all changes.

    Visual studio code’s integrated git support help us to compare the code by double clicking on the file OR Use git diff HEAD

    You can also undo file changes at the last commit. Use git checkout -- file_name

    5) Create remote repositories

    Till now we have created a local repository. But in order to push it to remote server. We need to add a remote repository in server.

    Use git remote add origin server_git_url

    Then push it to server repository

    Use git push -u origin master

    Let assume some time has passed. We have invited other people to our project who have pulled our changes, made their own commits, and pushed them.

    So to get the changes from our team members, we need to pull the repository.

    Use git pull origin master

    6) Create Branches

    Lets think that you are working on a feature or a bug. Better you can create a copy of your code(Branch) and make separate commits to. When you have done, merge this branch back to their master branch.

    Use git branch branch_name

    Now you have two local branches i.e master and XXX(new branch). You can switch branches using git checkout master OR git checkout new_branch_name

    Commiting branch changes using git commit -m message

    Switch back to master using git checkout master

    Now we need to merge changes from new branch into our master Use git merge branch_name

    Good! You just accomplished your bugfix Or feature development and merge. Now you don’t need the new branch anymore. So delete it using git branch -d branch_name

    Now we are in the last step to push everything to remote repository using git push

    Hope this will help you

    0 讨论(0)
  • 2020-12-02 05:02

    Have a look at git for designers for great one page article/high level intro to the topic. (That link is broken: Here is a link to another Git for Designers )

    I would start at http://git-scm.com/documentation, there are documents and great video presentations for non-software-developer/cs users. Git for beginners have some basic stuff.

    0 讨论(0)
  • 2020-12-02 05:02

    I would suggest this three for beginners

    http://git-scm.com/docs/gittutorial

    https://tutsplus.com/course/git-essentials/ (video tutorial)

    http://lifehacker.com/5983680/how-the-heck-do-i-use-github (gihub)

    0 讨论(0)
  • 2020-12-02 05:07

    I really like the O'Reilly book "Version Control with Git". I read it cover-to-cover and now I'm very comfortable with advanced git topics.

    0 讨论(0)
提交回复
热议问题