How To Update My Local Git Repo
git - the simple guide
merely a unproblematic guide for getting started with git. no deep shit ;)
add & commit
You can propose changes (add it to the Alphabetize) using
git add <filename>
git add *
This is the first step in the basic git workflow. To actually commit these changes use
git commit -1000 "Commit message"
Now the file is committed to the HEAD, but non in your remote repository yet.
pushing changes
Your changes are at present in the Head of your local working copy. To send those changes to your remote repository, execute
git push origin primary
Alter master to whatever branch y'all want to push your changes to.
If you have not cloned an existing repository and desire to connect your repository to a remote server, you demand to add together it with
git remote add origin <server>
Now y'all are able to push your changes to the selected remote server
branching
Branches are used to develop features isolated from each other. The master branch is the "default" co-operative when you create a repository. Use other branches for evolution and merge them dorsum to the master branch upon completion.
create a new branch named "feature_x" and switch to it using
git checkout -b feature_x
switch back to chief
git checkout master
and delete the branch again
git co-operative -d feature_x
a branch is not available to others unless you button the branch to your remote repository
git push origin <branch>
update & merge
to update your local repository to the newest commit, execute
git pull
in your working directory to fetch and merge remote changes.
to merge another co-operative into your active branch (eastward.g. master), use
git merge <branch>
in both cases git tries to automobile-merge changes. Unfortunately, this is not e'er possible and results in conflicts. You are responsible to merge those conflicts manually by editing the files shown by git. After irresolute, you demand to marking them every bit merged with
git add <filename>
before merging changes, y'all tin can besides preview them by using
git unequal <source_branch> <target_branch>
tagging
information technology's recommended to create tags for software releases. this is a known concept, which too exists in SVN. Y'all can create a new tag named 1.0.0 by executing
git tag 1.0.0 1b2e1d63ff
the 1b2e1d63ff stands for the beginning 10 characters of the commit id you want to reference with your tag. You tin get the commit id by looking at the...
log
in its simplest form, you lot can study repository history using.. git log
Yous can add a lot of parameters to make the log wait like what you want. To see only the commits of a certain writer:
git log --writer=bob
To see a very compressed log where each commit is one line:
git log --pretty=oneline
Or maybe you lot want to see an ASCII art tree of all the branches, decorated with the names of tags and branches:
git log --graph --oneline --decorate --all
See just which files have changed:
git log --name-condition
These are simply a few of the possible parameters y'all can utilise. For more, see git log --help
replace local changes
In case you did something incorrect, which for sure never happens ;), you can replace local changes using the command
git checkout -- <filename>
this replaces the changes in your working tree with the last content in Caput. Changes already added to the index, as well as new files, will exist kept.
If you instead want to driblet all your local changes and commits, fetch the latest history from the server and betoken your local principal branch at it like this
git fetch origin
git reset --hard origin/chief
Source: https://rogerdudler.github.io/git-guide/

0 Response to "How To Update My Local Git Repo"
Post a Comment