[cs615asa] HW#N: Attend a relevant Meetup/Talk/community event

Sneha Sheth ssheth6 at stevens.edu
Thu Apr 14 22:32:39 EDT 2016


Hi All,

I attended the DevOps meetup held at Addteq in Princeton, NJ on 11 February
2016. The talk was on "Practical Git Tips and Tricks".

The meetup was held with equal emphasis on a talk with demonstration and
networking. The demonstration's main focus was going through different git
commands that were compiled together keeping day to day scenarios and use
cases in mind. The following git commands were explained:

1. git stash
This command is used when you want to save the changes done in your local
directory and start again with a clean working directory. The current copy
then points to the latest HEAD commit.

2. git remote set-url origin <repo-of-your-git-url>
This command is used to change the Git URL from HTTPS to SSH or to
relocate/point your working directory to another Git URL.

3. git remote set-url [--push] <name> <new-url> [<old-url>]
This command is especially useful when you have Git mirroring setup. You
can set the pull URL to the master one and the push URL to the mirror node.

4. git reset --soft origin/master
This command will rollback your branch to the same commit as origin/master
and saves all your commits to staging.
There are three modes of reset:
-soft
-mixed
-hard

5. To delete an incorrect commit in Git, you can use any of the following:
git reset --hard <commit-id> where commit-id is the id of a specific commit.

If the wrong commit you made is already pushed then you will have to do a
force push. Usually force push is disabled for users as that might have
adverse effects on the repository if someone does a force push to the
master branch by mistake.
git push origin HEAD --force

However, if someone has already pulled from the incorrect commit and push
you made it is better to just start off with a new branch.

6. Undoing a Git merge commit
-Rewind your branch to the point you want to unmerge (git reset --hard
<commit>)
-Remerge any lines if needed (git merge <branch-name>)
-Once you rewind and unmerge you can work on the newly unmerged line and
commit at a later point or ignore it.

7. Dealing with merge conflicts
-Git conflicts occur only on the local copy and not on the remote server.
-Run the "git status" command to find where the conflict is.
-To accept local/our copy: git checkout --ours path/<file-name>
-To accept their/remote copy: git checkout --theirs path/<file-name>

8. Appending to commit messages in Git
git commit --amend
You can only modify the most recent commit using the above command.
But if the commit is already pushed then you need to use: git push --force
origin <branch-name>. Again, involving a force push anytime is not a good
practice.

9. Delete a Git branch both locally and remotely
-Local: git branch -D <branch-name>
-Remote: git push origin --delete <branch-name>

The talk also explained git submodules briefly.
-It helps split large projects into smaller pieces.
-It allows you to keep a Git repository inside your current Git repository.

I chose this event as I use and am interested in learning more about Git
and it's variations.

Even though I use it a lot of times these tips and commands will help me
improve my skills and especially resolve merge conflicts which usually are
difficult to resolve if the right commands are not used at the right time.
I understood a lot of tips to rollback yet stash the local changes so that
you don't lose those.

Overall the event was a good learning experience and more than just facts I
got to learn actual commands and see a live demonstration of how each one
works which I think is definitely is a huge plus for any beginner.

Thanks,
Sneha
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.stevens.edu/pipermail/cs615asa/attachments/20160414/255a7cec/attachment.html>


More information about the cs615asa mailing list