Using git

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Using git

Civil Guy
I'm new to using git.  I think I'd like to use it locally with a Linux / Ubuntu command line.

I followed the instructions to clone LibreCAD to my laptop, then modified a couple files before I figured out that that was not the right way to go.  I'd like to revert those files to the master-branch version, then update my local files with the current updates to the master branch.

How can I do that?
Reply | Threaded
Open this post in threaded view
|

Re: Using git

LordOfBikes
Administrator
If you haven't added the modification to the index yet, you can do a checkout to revert changes.

Use
git status
to see if any files are added to commit.
Or use
git diff
If you see diffs, the modifications are not added to the index yet.
With
git diff --cached
you can also check if there are any files to be committed in the index.

So when the index is empty, there is no output with
git diff --cached
then use this:
git checkout master
git pull

When you have modifications in the index, you have to reset your repo this way:
git reset --hard
git pull
This will revert the modifications in the working tree and also reset the index.

You may also have a look at these resources:
git tutorial: http://www-cs-students.stanford.edu/~blynn/gitmagic/
git reference: https://git-scm.com/docs
investing less than half an hour into Search function can save hours or days of waiting for a solution
Reply | Threaded
Open this post in threaded view
|

Re: Using git

gulshannegi
In reply to this post by Civil Guy
Git is software for tracking changes in any set of files, usually used for coordinating work among programmers collaboratively developing source code during software development. Its goals include speed, data integrity, and support for distributed, non-linear workflows. some of the most used git commands are:

git init: Initializes a new Git repository. Until you run this command inside a repository or directory, it’s just a regular folder. Only after you input this does it accept further Git commands.

git config: Short for “configure,” this is most useful when you’re setting up Git for the first time.

git help: Forgot a command? Type this into the command line to bring up the 21 most common git commands. You can also be more specific and type “git help i2nit” or another term to figure out how to use and configure a specific git command.

git status: Check the status of your repository. See which files are inside it, which changes still need to be committed, and which branch of the repository you’re currently working on.

git add: This does not add new files to your repository. Instead, it brings new files to Git’s attention. After you add files, they’re included in Git’s “snapshots” of the repository.

git commit: Git’s most important command. After you make any sort of change, you input this in order to take a “snapshot” of the repository. Usually it goes git commit -m “Message here.”The -m indicates that the following section of the command should be read as a message.

git checkout: Literally allows you to “check out” a repository that you are not currently inside. This is a navigational command that lets you move to the repository you want to check. You can use this command as git checkout masterto look at the master branch, or git checkout cats to look at another branch.

git branch: Working with multiple collaborators and want to make changes on your own? This command will let you build a new branch, or timeline of commits, of changes and file additions that are completely your own. Your title goes after the command. If you wanted a new branch called “cats,” you’d type git branch cats.

git merge: When you’re done working on a branch, you can merge your changes back to the master branch, which is visible to all collaborators. git merge cats would take all the changes you made to the “cats” branch and add them to the master.

git push: If you’re working on your local computer, and want your commits to be visible online on GitHub as well, you “push” the changes up to GitHub with this command.

git pull: If you’re working on your local computer and want the most up-to-date version of your repository to work with, you “pull” the changes down from GitHub with this command
Life does not give second chance so make it perfect in forst attempt